Redis版本特性

 redis


Redis Bitmap 应用限制

Redis 位图是字符串数据类型的扩展,可以将字符串视为位向量。

img

SETBIT key offset value

当 key 不存在时,将创建一个新的字符串值。字符串长度要确保可以包含 offset。 offset 参数必须大于或等于0,小于2^32(这将位映射限制为512MB)。当键处的字符串增长时,添加的位被设置为0。

2^32bit / 8 / 1024 / 1024 = 512MB

8 * 1024 * 1024 * 512 = 2^32

两点限制:

  • offset的最大长度是 unsigned i32,即取值范围是[0, 4294967295];
  • 如果首次写入4294967295,会直接分配到 512MB 的内存,内存占用比较多之外也会有一定的停顿;

Redis 6.0.0 Released Apr 30 2020

what’s new in Redis 6.0?

  • XCLAIM AOF/replicas propagation fixed.

  • Client side caching: new NOLOOP option to avoid getting notified about changes performed by ourselves.

  • ACL GENPASS now uses HMAC-SHA256 and have an optional “bits” argument. It means you can use it as a general purpose “secure random strings” primitive!

  • Cluster “SLOTS” subcommand memory optimization.

  • The LCS command is now a subcommand of STRALGO.

  • Meaningful offset for replicas as well. More successful partial resynchronizations.

  • Optimize memory usage of deferred replies.

  • Faster CRC64 algorithm for faster RDB loading.

  • XINFO STREAM FULL, a new subcommand to get the whole stream state.

  • CLIENT KILL USER <username>.

  • MIGRATE AUTH2 option, for ACL style authentication support.

  • Other random bugfixes.

Redis 5.0.0 Released Oct 17 2018

what’s new in Redis 5.0?

  • The new Stream data type. https://redis.io/topics/streams-intro

  • New Redis modules APIs: Timers, Cluster and Dictionary APIs.

  • RDB now store LFU and LRU information.

  • The cluster manager was ported from Ruby (redis-trib.rb) to C code inside redis-cli. Check redis-cli --cluster help for more info.

  • New sorted set commands: ZPOPMIN/MAX and blocking variants.

  • Active defragmentation version 2.

  • Improvemenets in HyperLogLog implementations.

  • Better memory reporting capabilities.

  • Many commands with sub-commands now have an HELP subcommand.

  • Better performances when clients connect and disconnect often.

  • Many bug fixes and other random improvements.

  • Jemalloc was upgraded to version 5.1

  • CLIENT UNBLOCK and CLIENT ID.

  • The LOLWUT command was added. http://antirez.com/news/123

  • We no longer use the “slave” word if not for API backward compatibility.

  • Differnet optimizations in the networking layer.

  • 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.
  • Dynamic HZ to balance idle CPU usage with responsiveness.

  • The Redis core was refactored and improved in many ways.

Redis 4.0.0 Released Jul 4 2017

what’s new in Redis 4.0?

  • 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

  • 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.

  • 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

  • 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 as DEL but working in a non blocking way. Similarly an ASYNC option was added to FLUSHALL and FLUSHDB in order to let the entire dataset or a single database to be freed asynchronously.

  • 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.

  • 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.

  • 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 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 is now able to defragment the used memory and reclaim space incrementally while running. See the example redis.conf for more information.

  • 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.

  • SWAPDB command: ability to completely and immediately (no latency) replace two Redis databases.

  • Improvements to dict.c, the Redis hash table implementation.

  • Security improvements mapping POST and Host: commands to QUIT in order to prevent cross protocol scripting attacks.

  • RPUSHX and LPUSHX now accept a variable number of elements.

  • Reporting of additional memory used by copy on write in the INFO output.

  • Serious refactoring of many core parts of Redis.

Redis 3.0.0 Released Apr 1 2015

What’s new in Redis 3.0?

  • Redis Cluster: a distributed implementation of a subset of Redis.

  • New “embedded string” object encoding resulting in less cache misses. Big speed gain under certain work loads.

  • AOF child -> parent final data transmission to minimize latency due to “last write” during AOF rewrites.

  • Much improved LRU approximation algorithm for keys eviction.

  • WAIT command to block waiting for a write to be transmitted to the specified number of slaves.

  • MIGRATE connection caching. Much faster keys migraitons.

  • MIGRATE new options COPY and REPLACE.

  • CLIENT PAUSE command: stop processing client requests for a specified amount of time.

  • BITCOUNT performance improvements.

  • CONFIG SET accepts memory values in different units (for example you can use “CONFIG SET maxmemory 1gb”).

  • Redis log format slightly changed reporting in each line the role of the instance (master/slave) or if it’s a saving child log.

  • INCR performance improvements.