gems redis 6.1.0

one hour ago

This is a minor release of the redis and redis-clustering gems. It adds the Redis 8.12 commands (BLESS key protection, set member expiration, ZMOVE, BITRANGEINTARRAY), the Redis 8.8 array commands and keyspace notification support, and fills in command coverage for Redis 7.0 through 8.6 (vector sets, compare-and-set, hot key tracking, functions).

Requires Ruby 3.2+ and works with Redis server 6.0+. Each new command needs the server version named next to it. All commands added in this release are available on Redis::Cluster unless noted otherwise.

🚀 New features

  • BLESS key-protection commands (Redis 8.12): bless_get, bless_set, bless_clear, bless_scan and bless_scan_each. Redis::Distributed implements all but bless_scan, whose cursor cannot span ring nodes; use bless_scan_each there. (#1395)
  • Set member expiration (Redis 8.12): sexpire, spexpire, sexpireat, spexpireat, sttl, spttl, sexpiretime, spexpiretime and spersist, with the nx:/xx:/gt:/lt: condition options, plus saddex with mnx:/mxx: and the ex:/px:/exat:/pxat:/keepttl: expiry options. All are available on Redis::Distributed. (#1405)
  • zmove, bzmove and zmovemember (Redis 8.12). Available on Redis::Distributed. (#1411)
  • bitrangeintarray (Redis 8.12). Available on Redis::Distributed. (#1409)
  • Query Engine vector fields pass every attribute through, so algorithm-specific ones such as compression: "SQ8" and training_threshold: (Redis 8.12) need no special handling. (#1397)
  • Array commands (Redis 8.8): arset, arget, armset, armget, argetrange, arlen, arcount, ardel, ardelrange, arinsert, arseek, arnext, arlastitems, arring, arscan, argrep, arop and arinfo. All are available on Redis::Distributed. (#1371)
  • increx with by:, lbound:/ubound:/saturate: and the ex:/px:/exat:/pxat:/persist:/enx: expiry options, and xnack (Redis 8.8). increx is available on Redis::Distributed. (#1372)
  • json_set now accepts fpha: to store a numeric array as a packed floating-point array, and the sorted set union/intersection commands accept aggregate: "count" (Redis 8.8). (#1373)
  • Keyspace notifications: channel builders and a binary-safe parser for the classic __keyspace@*/__keyevent@* channels and the Redis 8.8 subkey notification families (Redis::KeyspaceNotifications), plus a manager (Redis#keyspace_notifications) that owns a dedicated connection, dispatches typed Notification objects to handlers, and automatically re-subscribes after connection loss (on_reconnect signals the lossy gap). Enabling notify-keyspace-events on the server remains the operator's responsibility. Not supported by Redis::Distributed. See the user guide. (#1375)
  • Hot key tracking (Redis 8.6): hotkeys_start, hotkeys_get, hotkeys_stop and hotkeys_reset. A tracking session is state of a single server, so Redis::Cluster and Redis::Distributed raise NotImplementedError, also inside pipelined/multi; connect to a single node with Redis.new(host:, port:) instead. See the README "Hot key tracking (HOTKEYS)" section. (#1408)
  • xadd now accepts idmp: and idmpauto: for idempotent production, and add xcfgset (Redis 8.6). (#1402)
  • xreadgroup now accepts claim: (Redis 8.4). (#1401)
  • Compare-and-set and compare-and-delete (Redis 8.4): set accepts ifeq:, ifne:, ifdeq: and ifdne:, and add delex and digest. Redis::XXH3.hexdigest computes the XXH3-64 digest of a value locally in pure Ruby, so ifdeq:/ifdne: need no DIGEST round trip. Available on Redis::Distributed. See the README "Compare-and-set (CAS/CAD)" section. (#1393)
  • xdelex and xackdel; xadd and xtrim now accept policy: (:keepref, :delref or :acked); cluster('slot-stats', ...) replies are reshaped into [slot, Hash] pairs (Redis 8.2). (#1391, #1392)
  • Vector sets (Redis 8.0): vadd, vcard, vdim, vemb, vlinks, vsim, vrem, vismember, vrandmember, vrange (Redis 8.4), vinfo, vsetattr and vgetattr. All are available on Redis::Distributed. (#1382)
  • hgetdel, hgetex and hsetex (Redis 8.0). All are available on Redis::Distributed. (#1389)
  • hexpireat, hpexpireat, hexpiretime, hpexpiretime and hpersist; hexpire and hpexpire now accept the nx:/xx:/gt:/lt: condition options (Redis 7.4). All are available on Redis::Distributed. (#1374)
  • waitaof (Redis 7.2). (#1387)
  • Redis functions (Redis 7.0): function, fcall and fcall_ro. All are available on Redis::Distributed. (#1383)
  • sort_ro, lcs, sintercard and zintercard (Redis 7.0). All are available on Redis::Distributed. (#1384)
  • info now accepts several sections at once, shutdown accepts save:, now:, force: and abort:, xgroup accepts entriesread:, and add xsetid with entriesadded: and maxdeletedid: (Redis 7.0). (#1385)
  • Ractors: the constants under Redis, such as the reply-reshaping lambdas and Redis::Future::FutureNotReady, are now shareable, so commands and pipelines work in non-main Ractors. Add redis/ractorize, which freezes Redis::Client::ERROR_MAPPING and Redis::Cluster::Client::ERROR_MAPPING so that errors can be translated there; require it in the main Ractor after anything that adds errors to the mappings. See the README "Ractors" section. (#1403)

Cluster gem (redis-clustering) only

  • bless_get, bless_set and bless_clear route by the key's hash slot; bless_scan and bless_scan_each walk every shard the way scan does, with the node index encoded in the returned cursor, so a full iteration covers the whole cluster. Inside pipelined/multi, bless_scan is sent to a single node and returns only that node's keys. (#1395)
  • Redis::Cluster#keyspace_notifications: a cluster-aware keyspace notification manager that subscribes on every primary (notifications are node-local in cluster and are not forwarded on the cluster bus, so a plain subscribe silently receives ~1/N of the events), dispatches parsed notifications from a single dispatcher thread, and reconciles reactively on node connection errors (#refresh is also public for post-scale-out reconciliation). Requires notify-keyspace-events to be enabled on every node, replicas included. (#1375)
  • waitaof is sent to every primary and each count in the reply is the minimum across primaries, so thresholds keep their single-node meaning. (#1387)
  • Redis::Cluster.new now accepts command_routings:, a { 'command' => { request_policy:, response_policy: } } hash merged over the driver's routing table. (#1387)

🐛 Bug fixes

  • Make hset return 0 without calling the server when given an empty hash, instead of raising ERR wrong number of arguments for 'hset' command. (#1290, #1404)
  • Make Redis::Distributed#multi release the watched key once the transaction runs or raises, so that commands on keys stored on other nodes no longer raise CannotDistribute after a watch and multi sequence. An explicit #unwatch or another #multi after the transaction still works as before. (#1407)
  • Fix a race where calling unsubscribe/punsubscribe from another thread while the subscribed client was concurrently tearing down raised NoMethodError instead of Redis::SubscriptionError. (#1375)
  • With sentinels, errors raised by pipelined and multi are now translated to Redis::* errors instead of surfacing as RedisClient::* errors. (#1396)
  • zrank and zrevrank with with_score: true return nil for a missing key or member instead of [nil, nil], and RESP2 nan replies become Float::NAN (Redis 7.2). (#1388)
  • xautoclaim replies now include a 'deleted' key with the ids that were deleted from the stream and dropped from the PEL (Redis 7.0; always [] on 6.2). (#1386)
  • migrate inside pipelined/multi now falls back to the client's db and timeout instead of the pipeline's. (#1381)
  • himport_prepare snapshots the field names at preparation time, so mutating the strings afterwards no longer changes the schema used for automatic re-preparation. (#1380)
  • ft_aggregate now sends the right LOAD field count when the fields are given as nested arrays. (#1379)
  • In pipelined(exception: false), errors are no longer passed through the reply reshaping lambdas, the flag now also applies to multi inside the pipeline, and when EXEC aborts the transaction's command futures hold the error instead of staying unresolved. (#1377)
  • Only fall back to RESP2 when HELLO itself fails with NOPROTO, instead of on any command error whose message contains NOPROTO. (#1376)
  • Redis::HashRing#remove_node filters the ring positions once instead of once per replica. (#1378)

🧰 Maintenance

  • Pin redis-client to 0.31.0 (previously 0.30.1). (#1400)
  • The cluster gem pins redis-cluster-client to 0.18.0 (previously 0.16.7): adds the node-by-node BLESS SCAN routing bless_scan relies on, routes the informational CLUSTER, SCRIPT, MEMORY and CLIENT subcommands by their command tips instead of rejecting them, follows MOVED redirections to nodes not yet in the topology, and splits multi-key unlink, exists and touch across slots the way del already was. (#1375, #1395)
  • Document the himport_auto_prepare client option. (#1370)
  • Add CONTRIBUTORS.md. (#1410)

Upgrade notes

  1. zrank/zrevrank with with_score: true now return nil instead of [nil, nil] for a missing key or member, and xautoclaim replies carry an extra 'deleted' key; adapt code that destructures those replies.
  2. Cluster users: informational CLUSTER, SCRIPT, MEMORY and CLIENT subcommands that the driver used to reject are now routed by their command tips, and multi-key unlink, exists and touch no longer need all keys in one slot.
  3. Everything else is drop-in.

Don't miss a new redis release

NewReleases is sending notifications on new releases.