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

xiaoxiao2024-05-08  24

点击上方“芋道源码”,选择“置顶公众号”

技术文章第一时间送达!

源码精品专栏

 

精尽 Dubbo 原理与源码 69 篇

精尽 Netty 原理与源码 61 篇

中文详细注释的开源项目

Java 并发源码合集

RocketMQ 源码合集

Sharding-JDBC 源码解析合集

Spring MVC 和 Security 源码合集

MyCAT 源码解析合集

来源: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-intro2. 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.113. CLIENT UNBLOCK and CLIENT ID.14. The LOLWUT command was added. http://antirez.com/news/12315. 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 introductionof 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-readyexperience 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 somethingfun 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



如果你对 Dubbo / Netty 等等源码与原理感兴趣,欢迎加入我的知识星球一起交流。长按下方二维码噢

目前在知识星球更新了《Dubbo 源码解析》目录如下:01. 调试环境搭建02. 项目结构一览03. 配置 Configuration04. 核心流程一览

05. 拓展机制 SPI

06. 线程池

07. 服务暴露 Export

08. 服务引用 Refer

09. 注册中心 Registry

10. 动态编译 Compile

11. 动态代理 Proxy

12. 服务调用 Invoke

13. 调用特性 

14. 过滤器 Filter

15. NIO 服务器

16. P2P 服务器

17. HTTP 服务器

18. 序列化 Serialization

19. 集群容错 Cluster

20. 优雅停机

21. 日志适配

22. 状态检查

23. 监控中心 Monitor

24. 管理中心 Admin

25. 运维命令 QOS

26. 链路追踪 Tracing

... 一共 69+ 篇

目前在知识星球更新了《Netty 源码解析》目录如下:01. 调试环境搭建02. NIO 基础03. Netty 简介04. 启动 Bootstrap

05. 事件轮询 EventLoop

06. 通道管道 ChannelPipeline

07. 通道 Channel

08. 字节缓冲区 ByteBuf

09. 通道处理器 ChannelHandler

10. 编解码 Codec

11. 工具类 Util

... 一共 61+ 篇

目前在知识星球更新了《数据库实体设计》目录如下:

01. 商品模块02. 交易模块03. 营销模块04. 公用模块

... 一共 17+ 篇

目前在知识星球更新了《Spring 源码解析》目录如下:

01. 调试环境搭建02. IoC Resource 定位03. IoC BeanDefinition 载入

04. IoC BeanDefinition 注册

05. IoC Bean 获取

06. IoC Bean 生命周期

... 一共 35+ 篇


文章转载自公众号:阿飞的博客

转载请注明原文地址: https://www.6miu.com/read-5015226.html

最新回复(0)