Redis5.0版本特性介绍

Introduction to the Redis 5 release

Redis 5 is a release focused on a few important features. While Redis 4
was very very focused on operations, Redis 5 changes are mostly user-facing,
with the implementation of new data types and operations on top of existing
types. The following are the major features of this release:

Redis5是一个聚焦到几个重要改进的版本。Redis4是非常关注操作,Redis5改进是非常关注用户界面,
新增了新的数据类型的实现和现有数据类型的相关操作。

  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 slaves / AOF.
    • Lua scripts can now timeout and get in -BUSY state in the slave as well.
  18. Dynamic HZ to balance idle CPU usage with responsiveness.
  19. The Redis core was refactored and improved in many ways.
  1. 新增Stream数据类型。
  2. 新增Redis模块API:定时器、集群和字典API。
  3. RDB现在存储LFU和LRU信息。
  4. 集群管理器被从Ruby(redis-trib.rb)移植到C代码内部redis-cli。
  5. 新增排序集合命令:ZPOPMIN/MAX和(blocking variants)阻塞版本命令。
  6. 第二版主动碎片整理。
  7. HyperLogLog实现改进
  8. 更好的内存使用报告功能。
  9. 很多带有子命令的命令现在增加HELP子命令。
  10. 在客户端连接和断开频繁的情况提供更好的性能。
  11. 很多bug修复和其他随机改进。
  12. 升级Jemalloc到5.1版本。
  13. CLIENT UNBLOCK和CLIENT ID命令。
  14. 增加LOLWUT命令(快速生成一些图形的与技术使用无关的有趣命令)。
  15. 如果不是为了向后兼容API,我们不再使用"slave"这个词。
  16. 网络层改进
  17. Lua改进:
    • 将Lua脚本传播到从节点/AOF。
    • Lua脚本可以超时,同时在超时时可以在从节点获取到-BUSY的状态。
  18. 动态HZ来调整空闲CPU使用率和响应速度。(hz参数用于指定Redis定期任务的执行频率,这些任务包括关闭超时的客户端连接、主动清除过期key等)
  19. Redis核心被重构和改进了许多方面。

Migrating from 4.0 to 5.0

Redis 4.0 is mostly a strict subset of 5.0, you should not have any problem
upgrading your application from 4.0 to 5.0. However this is a list of small
non-backward compatible changes introduced in the 5.0 release:

  • redis-cli now implements the cluster management tool. We still ship the
    old redis-trib, but new fixes will be implemented only in redis-cli.
    See redis-cli --cluster help for more info.

  • The RDB format changed. Redis 5.0 is still able to read 4.0 (and all the
    past versions) files, but not the other way around.

  • Certain log formats and sentences are different in Redis 5.0.

  • Now by default maxmemory is ignored by slaves, and used only once a slave
    is promoted to master. It means that in setups where you want slaves to
    enforce maxmemory in an independent way from the master (that will anyway
    stream the key eviction DEL commands), you should active this feature manually
    and make sure you understand that it breaks consistency if writes are not
    always idempotent. TLDR: the new behavior is much better for 99.999% of use
    cases, revert it if you really know what you are doing.

  • Scripts are only replicated by their effects and not by sending EVAL/EVALSHA
    to slaves or the AOF log itself. This is much better in the general case
    and in the future we want to totally remove the other possiblity of
    propagating scripts the old way (as EVAL). However you can still turn this
    back to the default via the non-documented (if not here) Redis configuration
    directive “lua-replicate-commands yes” or
    “DEBUG lua-always-replicate-commands 0”. However note that Redis 6 may
    completely remove such feature.

  • Because of the above change related to scripts replication, certain Redis
    commands that in Redis 4 had their result ordered lexicographically before
    being passed to Lua via the return value of redis.call(), now have a behavior
    more similar to calling the commands directly from a normal client. For
    instance the ordering of elements returned by SMEMBERS or SDIFF is now
    undetermined in Lua, exactly as it is by default when calling the commands
    from a non-scripting context.

Redis 4.0基本是Redis 5.0的严格子集,您从4.0 升级到5.0应该没啥问题。但是5.0发布时增加了一些非向后兼容的改变:

  • redis-cli现在实现集群管理工具。我们仍然发布旧的redis-trib,但新的修复将只在redis-cli中实现。使redis-cli --cluster help可以查看更多帮助信息。
  • RDB格式变化了。Redis 5.0仍然可以读取4.0(和所有以前的版本)文件,但是反过来是读不了的。
  • Redis5.0的一些日志格式和句子变化了。
  • 现在 maxmemory通常被从节点忽略掉,除非从节点被提升为主节点才会被用一次。这意味着如果您想让从节点强制设置与master节点不同的maxmemory的情况下(通常会触发键删除操作),您必须手动激活这个功能,并确保您明白如果写入不是幂等的话,这将会破坏一致性。TLDR:新的行为适用的99.999%的使用情况,除非确定要做什么,否则不要回退它。
  • 脚本只会根据它们的效果进行复制,而不是发送EVAL/EVALSHA到从节点或AOF日志本身。这是一般情况下更好的的方法,并且将来我们将完全移除其他可能的方法(如EVAL)。但是您仍然可以通过非公开的配置选项"lua-replicate-commands yes"或"DEBUG lua-always-replicate-commands 0"来回退到默认值。但是Redis6可能会完全移除这个功能。
  • 因为上面的改变相关的脚本复制,某些Redis命令在Redis 4中的返回值已经按字母顺序排列在Lua中,现在从Lua中直接调用这些命令的行为会和普通的客户端更为相似。例如,SMEMBERS或SDIFF的返回值在Lua中是不确定的, 因为默认是被命令从一个非脚本环境调用的。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值