翻译文章,原文地址:https://raw.githubusercontent.com/antirez/redis/4.0/00-RELEASENOTES
So, what’s new in Redis 4.0?
Major features (主要特性)
Redis modules system. Redis now allows developers to write modules that can extend the Redis functionalities and implement new data types. The module API implements a complete abstraction layer that separates the Redis core from the module implementation, allowing the same module to be loaded by different versions of Redis without modifications. See the modules documentation here for more info: https://github.com/antirez/redis/blob/unstable/src/modules/INTRO.md
Redis模块系统。Redis现在允许开发者写模块,以扩展Redis功能和实现新数据类型。模块API实现了一个完整的抽象层,使得模块可以被不同版本的Redis加载。查看模块文档获取更多信息:https://github.com/antirez/redis/blob/unstable/src/modules/INTRO.md
Partial Replication (PSYNC) version 2. The replication protocol was enhanced (in a backward compatible way, so that 4.0 can still act as a slave of older instances) in order to be able to partially resynchronize slaves and masters in conditions where it was impossible in the past: after a master switch because of a failover and when a slave instance is restared. Even masters turned into slaves will usually be able to partially resynchronize with the new master, if the new master was a former slave of the old master instance. The way the replication work for chained slaves (sub-slaves) is now very different, and each slave receives the same replication stream generated by the top-level master.
局部复制(PSYNC)版本2。复制协议被增强(以一种可以向后兼容的方式,以便4.0可以作为旧版本的从属实例),以便在主从实例之间可以实现部分同步,而之前是主从切换或从实例重启后全量同步数据。即使主实例被切换为从属实例,新的主实例是旧的主实例的从属实例,通常仍然可以进行部分同步。主实例向关联的从属实例(及更下级从属实例)复制工作的实现方式现在非常不通,每个从实例接收的都是顶级主实例生成的相同的同步流。
Cache eviction improvements. Redis 4.0 implements LFU (Least Frequently Used) as a new eviction algorithm, and improves the functionality, performances and precision of the existing algorithms. This blog post contains info about the changes: http://antirez.com/news/109
缓存淘汰算法改进。Redis4.0实现了LFU(最少使用频次)算法作为新的淘汰算法,并且改进了现有算法的功能、性能和精度。本文档提供了更多信息:http://antirez.com/news/109
Lazy freeing of keys. Redis is now able to delete keys in the background in a different thread without blocking the server. The new
UNLINK
command is the same asDEL
but working in a non blocking way. Similarly anASYNC
option was added toFLUSHALL
andFLUSHDB
in order to let the entire dataset or a single database to be freed asynchronously.延迟释放键。Redis现在可以在后台在不阻塞服务器的情况下删除键。新的
UNLINK
命令是DEL
命令的一个变体,它以非阻塞的方式工作。同样,ASYNC
选项被添加到FLUSHALL
和FLUSHDB
中,以便整个数据集或单个数据库可以在后台异步释放。Mixed RDB-AOF format. If enabled the new format is used when rewriting the AOF file: the rewrite uses the more compact and faster to generate RDB format, and an AOF stream is appended to the file. This allows faster rewrites and reloads when using the AOF persistence.
提供混合RDB-AOF持久化格式。如果启用,当重写AOF文件时,新格式被使用:重写使用更紧凑和更快速生成的RDB格式,并且将AOF流被附加到文件中。这使得AOF持久化时可以更快的重写和重新加载。
A new MEMORY command, able to perform memory analysis of different kinds: troubleshooting of memory issues (with MEMORY DOCTOR, similar to LATENCY DOCTOR), reporting of the amount of memory used by a single key, more in-depth reporting of Redis memory usage compared to what the INFO command offers.
新增的MEMORY命令,能够执行不同类型的内存分析:内存问题调试(用MEMORY DOCTOR,类似于LATENCY DOCTOR),单个键的内存使用量的报告,与与INFO命令提供的内存使用量相比更详细的报告Redis内存使用量的报告。
Redis Cluster support for NAT / Docker. There are new functionalities in order to force cluster instances to announce specific sets of IP address, client and bus ports, to the rest of the cluster, regardless of the auto detected IP. This required a bus protocol change that will force users to mass-restart all the nodes of a Redis 3.2 installation in order to upgrade to 4.0.
Redis Cluster 支持 NAT / Docker.提供了新的功能来强制集群实例公布特定的IP地址、客户端和总线端口,到集群中的其他节点,无论自动检测到的IP是什么。这需要一个总线协议改变,需要强制用户将其安装的Redis 3.2的所有节点都批量重启,才能升级到4.0。
Redis uses now less memory in order to store the same amount of data. The gain depends a lot on the kind of dataset stored.
Redis现在使用更少的内存来存储相同的数据量。这个收益得益于存储的数据集的种类。
Redis is now able to defragment the used memory and reclaim space incrementally while running. See the example
redis.conf
for more information.Redis现在可以在运行时逐步释放内存和重新整理内存。请参阅示例
redis.conf
以获取更多信息。
Smaller features (较小的特性)
Improvements to the RDB format to support 64 bit lengths, binary sorted set scores, and more. The RDB file check utility now uses the same code base of the one used by Redis itself in order to load the RDB file in memory.
改进了RDB的格式来支持64位的长度,二进制的有序集分数等等。RDB文件检查工具现在使用Redis本身使用的编码来加载RDB文件到内存。
SWAPDB command: ability to completely and immediately (no latency) replace two Redis databases.
SWAPDB命令:能够完全和立即(无延迟)替换同实例下的两个Redis数据库。
Improvements to
dict.c
, the Redis hash table implementation.dict.c
的改进,改进Redis哈希表实现。Security improvements mapping POST and Host: commands to QUIT in order to prevent cross protocol scripting attacks.
安全改进,映射
POST
和Host:
命令到QUIT
命令,以防止跨协议脚本攻击。RPUSHX and LPUSHX now accept a variable number of elements. > RPUSHX和LPUSHX现在可以接受元素数量的变量。
Reporting of additional memory used by copy on write in the INFO output. > 在INFO输出中报告 COW 使用的额外内存。
Serious refactoring of many core parts of Redis. > 重构Redis的许多核心部分。
Redis 3.2 is mostly a strict subset of 4.0, you should not have any problem upgrading your application from 3.2 to 4.0. However this is a list of small non-backward compatible changes introduced in the 4.0 release:
Redis 3.2基本是4.0的严格子集,从3.2升级到4.0基本没什么问题,但是这是4.0发布时增加的一些小的非后退兼容性的更改:
- The Redis Cluster bus protocol of 4.0 is no longer compatible with Redis 3.2. This was needed in order to provide Docker / NAT compatibility to Redis Cluster. SO in order to upgrade a Redis Cluster to 4.0, a mass restart of all the instances is needed.
- Redis Cluster 总线协议4.0不再兼容Redis 3.2。这是为了提供Docker / NAT兼容性到Redis集群。
- Redis Cluster CLUSTER NODES output is now slightly different. Nodes addresses are now in the form host:port@bus-port instead of host:port. Clients should use CLUSTER SLOTS in order to fetch the cluster configuration however if they are still using CLUSTER NODES, they should be modified in order to ignore the @bus-port part.
- Redis Cluster集群CLUSTER NODES输出现在有点不同。节点地址现在是host:port@bus-port格式,而不是host:port。 客户端应该使用CLUSTER SLOTS来获取集群配置,但是如果仍然使用CLUSTER NODES,它们应该修改,以忽略@bus-port部分。
- Writable slaves do not propagate writes to their sub-slaves, so writes to writable slaves remain just local.
- 可写的从属节点不会传播写入到他们的下级从属,所以可写的从属节点的写入仍然是本地的。
- The RDB format changed. Redis 4.0 is still able to read 3.2 (and all the past versions) files, but not the other way around.
- RDB格式变了。Redis 4.0仍然可以读取3.2(和所有以前的版本)文件,但反过来不行。
- Certain log formats and sentences are different in Redis 4.0.
- Redis 4.0中的某些日志格式和句子有所变化。
- Certain INFO fields, especially related to replication, are now different.
- Redis 4.0中的某些INFO字段,特别是关于
replication
的相关字段有所变化。
- GEODIST, GEOPOS and GEOHASH return values changed for non existing keys: Previously the return value was inconsistent between non existing key and non existing elements. Now the return is always like if the key contains no elements if the key does not exist. So, for instance, “GEOHASH non_existing_key A B C” now returns an array of 3 NULL values as it should. In general this change should not break compatibility with the past since in the past two different forms were provided by the server and the new behavior is one of the two.
- GEODIST,GEOPOS和GEOHASH对于不存在的键的返回值变了: 以前的key不存在和key存在元素不存在时返回值不一致。现在两种情况返回的值差不多。例如,”GEOHASH non_existing_key A B C”现在返回的是三个NULL的数组。通常这个改变不会影响以前的行为,因为以前有两种方式处理这个命令,而新的返回两种情况的处理方式是一种。
- The SLOWLOG command entires contain additional two fields: the client address and name. This is documented in the SLOWLOG command online documentation.
SLOWLOG
命令条目包含额外两个字段:客户端地址和名称。这是在线文档中提到的。