前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >10 分钟不全面了解 Redis 5.0 新特性

10 分钟不全面了解 Redis 5.0 新特性

作者头像
芋道源码
发布2018-11-22 16:17:46
1.2K0
发布2018-11-22 16:17:46
举报

来源:https://www.jianshu.com/p/fa989a228d59

作为一统缓存江山的redis,正式发布了5.0稳定版(stable),激不激动,开不开森?Github链接:https://github.com/antirez/redis/releases/tag/5.0.0 ,让我们一起看看它带来了哪些振奋人心的新特性:

redis5.0 stable

官方列举特性如下:

======================================================
Redis 5.0.0     Released Wed Oct 17 13:28:26 CEST 2018
======================================================

what's new in Redis 5:

1. The new Stream data type. https://redis.io/topics/streams-intro
2. New Redis modules APIs: Timers, Cluster and Dictionary APIs.
3. RDB now store LFU and LRU information.
4. The cluster manager was ported from Ruby (redis-trib.rb) to C code
   inside redis-cli. Check `redis-cli --cluster help` for more info.
5. New sorted set commands: ZPOPMIN/MAX and blocking variants.
6. Active defragmentation version 2.
7. Improvemenets in HyperLogLog implementations.
8. Better memory reporting capabilities.
9. Many commands with sub-commands now have an HELP subcommand.
10. Better performances when clients connect and disconnect often.
11. Many bug fixes and other random improvements.
12. Jemalloc was upgraded to version 5.1
13. CLIENT UNBLOCK and CLIENT ID.
14. The LOLWUT command was added. http://antirez.com/news/123
15. We no longer use the "slave" word if not for API backward compatibility.
16. Differnet optimizations in the networking layer.
17. Lua improvements:
    - Better propagation of Lua scripts to replicas / AOF.
    - Lua scripts can now timeout and get in -BUSY state in the replica as well.
18. Dynamic HZ to balance idle CPU usage with responsiveness.
19. The Redis core was refactored and improved in many ways.

Redis开源社区版新特性

下面我们对一些重要特性进行更深入的了解。

Streams

全新的数据类型:Streams。官方把这个当做是最重要的改进(The most important user facing improvement is without doubts the introduction of the new general purpose data type after years: the streams. )。而且官方提到在发版本的几个小时前还在修复streams的问题,所以官方也不敢保证release版本是否有一些比较严重的BUG(T T),官方还是建议大家在生产环境不要使用streams,这样可能会有更好的体验,扎心了(People not using the streams can have probably a better production-ready experience with Redis 5)。

笔者接下来还会单独撰文剖析Streams,敬请关注。

cluster manager with c

redis终于还是抛弃了ruby,维护过redis3.x和redis4.x的都知道,主要依赖redis-trib.rb脚本,redis5.0彻底抛弃了它,将集群管理功能全部集成到完全用C写的redis-cli中。可以通过命令redis-cli --cluster help查看帮助信息。

LOLWUT

redis5.0新增的一个命令,官方对它的描述是:a piece of art inside a database command,翻译过来可以数据库命令中的一件艺术品(老外真幽默)。

这个方法源码注释如下: This file implements the LOLWUT command. The command should do something fun and interesting, and should be replaced by a new implementation at each new version of Redis。源码链接:https://github.com/antirez/redis/blob/5.0.0/src/lolwut5.c,有兴趣的同学可以看看redis作者在5.0版本中实现了些什么好玩的东西。

有兴趣的同学还可以延伸阅读:http://antirez.com/news/123

Lua改进

lua脚本能更好的传播到replicas/AOF。replicas也就是以前的slave,大家都知道redis的slave事件前段时间闹的沸沸扬扬,现在redis官方都改称replicas了,并且申明除非为了API向后兼容,否则不再使用slave这个词(We no longer use the "slave" word if not for API backward compatibility.)。

lua脚本现在还能支持超时,并且可以在replica中进入BUSY状态。

动态HZ

以前redis版本的hz都是固定的,5.0将hz动态化是为了平衡空闲CPU的使用率和响应能力。


其他一些比如HyperLogLog实现改进,RDB文件新增存储LFU和LRU信息,sorted set新增两个命令ZPOPMIN/MAX,Jemalloc升级到5.1等特性就不一一解读了。

Redis Enterprise Software新特性

Redis开源许可从AGPL 迁移到将 Apache v2.0 与 Commons Clause 相结合的许可证,下面介绍的这些特性不再是开源软件,而是源码可用(source available)。

备注:Commons Clause 的初衷是为了抵御一些不良行为。如那些使用源代码,却不对开源代码维护做出补偿的公司。” ---- Commons Clause 开发者兼 FOSSA 创始人 Kevin Wang。

support docker

现在官方版本正式支持在Docker容器上部署和运行Redis集群了。有了官方的镜像,你能非常容易并快速部署几个容器来运行一个可扩展的,高可用的Redis集群。想要了解更多请戳链接:https://redislabs.com/redis-enterprise-documentation/getting-started/docker/。

Redis Labs’ Modules

Redis Labs开发了3个模块,并且被Redis企业软件(简称RS)认证,这些模块是: RediSearch:这个模块将RS变成了一个基于内存的分布式全文索引和搜索引擎,感觉好牛逼的样子(ES表示不服)。 ReJSON:通过模块名称就知道,JSON作为Redis的内置数据类型。 ReBloom: RS具有可扩展的Bloom过滤器,并且是一个数据类型。Bloom过滤器是一种概率性的数据结构,在快速判断某些元素是否被包含在一个集合这方便表现的非常好。

参考

https://redislabs.com/redis-enterprise-documentation/overview/new-features-redis-enterprise/

https://raw.githubusercontent.com/antirez/redis/5.0/00-RELEASENOTES

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2018-10-24,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 芋道源码 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Redis开源社区版新特性
    • Streams
      • cluster manager with c
        • LOLWUT
          • Lua改进
            • 动态HZ
            • Redis Enterprise Software新特性
              • support docker
                • Redis Labs’ Modules
                • 参考
                相关产品与服务
                云数据库 Redis
                腾讯云数据库 Redis(TencentDB for Redis)是腾讯云打造的兼容 Redis 协议的缓存和存储服务。丰富的数据结构能帮助您完成不同类型的业务场景开发。支持主从热备,提供自动容灾切换、数据备份、故障迁移、实例监控、在线扩容、数据回档等全套的数据库服务。
                领券
                问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档