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
BLESSkey-protection commands (Redis 8.12):bless_get,bless_set,bless_clear,bless_scanandbless_scan_each.Redis::Distributedimplements all butbless_scan, whose cursor cannot span ring nodes; usebless_scan_eachthere. (#1395)- Set member expiration (Redis 8.12):
sexpire,spexpire,sexpireat,spexpireat,sttl,spttl,sexpiretime,spexpiretimeandspersist, with thenx:/xx:/gt:/lt:condition options, plussaddexwithmnx:/mxx:and theex:/px:/exat:/pxat:/keepttl:expiry options. All are available onRedis::Distributed. (#1405) zmove,bzmoveandzmovemember(Redis 8.12). Available onRedis::Distributed. (#1411)bitrangeintarray(Redis 8.12). Available onRedis::Distributed. (#1409)- Query Engine vector fields pass every attribute through, so algorithm-specific ones such as
compression: "SQ8"andtraining_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,aropandarinfo. All are available onRedis::Distributed. (#1371) increxwithby:,lbound:/ubound:/saturate:and theex:/px:/exat:/pxat:/persist:/enx:expiry options, andxnack(Redis 8.8).increxis available onRedis::Distributed. (#1372)json_setnow acceptsfpha:to store a numeric array as a packed floating-point array, and the sorted set union/intersection commands acceptaggregate: "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 typedNotificationobjects to handlers, and automatically re-subscribes after connection loss (on_reconnectsignals the lossy gap). Enablingnotify-keyspace-eventson the server remains the operator's responsibility. Not supported byRedis::Distributed. See the user guide. (#1375) - Hot key tracking (Redis 8.6):
hotkeys_start,hotkeys_get,hotkeys_stopandhotkeys_reset. A tracking session is state of a single server, soRedis::ClusterandRedis::DistributedraiseNotImplementedError, also insidepipelined/multi; connect to a single node withRedis.new(host:, port:)instead. See the README "Hot key tracking (HOTKEYS)" section. (#1408) xaddnow acceptsidmp:andidmpauto:for idempotent production, and addxcfgset(Redis 8.6). (#1402)xreadgroupnow acceptsclaim:(Redis 8.4). (#1401)- Compare-and-set and compare-and-delete (Redis 8.4):
setacceptsifeq:,ifne:,ifdeq:andifdne:, and adddelexanddigest.Redis::XXH3.hexdigestcomputes the XXH3-64 digest of a value locally in pure Ruby, soifdeq:/ifdne:need noDIGESTround trip. Available onRedis::Distributed. See the README "Compare-and-set (CAS/CAD)" section. (#1393) xdelexandxackdel;xaddandxtrimnow acceptpolicy:(:keepref,:delrefor: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,vsetattrandvgetattr. All are available onRedis::Distributed. (#1382) hgetdel,hgetexandhsetex(Redis 8.0). All are available onRedis::Distributed. (#1389)hexpireat,hpexpireat,hexpiretime,hpexpiretimeandhpersist;hexpireandhpexpirenow accept thenx:/xx:/gt:/lt:condition options (Redis 7.4). All are available onRedis::Distributed. (#1374)waitaof(Redis 7.2). (#1387)- Redis functions (Redis 7.0):
function,fcallandfcall_ro. All are available onRedis::Distributed. (#1383) sort_ro,lcs,sintercardandzintercard(Redis 7.0). All are available onRedis::Distributed. (#1384)infonow accepts several sections at once,shutdownacceptssave:,now:,force:andabort:,xgroupacceptsentriesread:, and addxsetidwithentriesadded:andmaxdeletedid:(Redis 7.0). (#1385)- Ractors: the constants under
Redis, such as the reply-reshaping lambdas andRedis::Future::FutureNotReady, are now shareable, so commands and pipelines work in non-main Ractors. Addredis/ractorize, which freezesRedis::Client::ERROR_MAPPINGandRedis::Cluster::Client::ERROR_MAPPINGso 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_setandbless_clearroute by the key's hash slot;bless_scanandbless_scan_eachwalk every shard the wayscandoes, with the node index encoded in the returned cursor, so a full iteration covers the whole cluster. Insidepipelined/multi,bless_scanis 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 plainsubscribesilently receives ~1/N of the events), dispatches parsed notifications from a single dispatcher thread, and reconciles reactively on node connection errors (#refreshis also public for post-scale-out reconciliation). Requiresnotify-keyspace-eventsto be enabled on every node, replicas included. (#1375)waitaofis 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.newnow acceptscommand_routings:, a{ 'command' => { request_policy:, response_policy: } }hash merged over the driver's routing table. (#1387)
🐛 Bug fixes
- Make
hsetreturn0without calling the server when given an empty hash, instead of raisingERR wrong number of arguments for 'hset' command. (#1290, #1404) - Make
Redis::Distributed#multirelease the watched key once the transaction runs or raises, so that commands on keys stored on other nodes no longer raiseCannotDistributeafter awatchandmultisequence. An explicit#unwatchor another#multiafter the transaction still works as before. (#1407) - Fix a race where calling
unsubscribe/punsubscribefrom another thread while the subscribed client was concurrently tearing down raisedNoMethodErrorinstead ofRedis::SubscriptionError. (#1375) - With sentinels, errors raised by
pipelinedandmultiare now translated toRedis::*errors instead of surfacing asRedisClient::*errors. (#1396) zrankandzrevrankwithwith_score: truereturnnilfor a missing key or member instead of[nil, nil], and RESP2nanreplies becomeFloat::NAN(Redis 7.2). (#1388)xautoclaimreplies 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)migrateinsidepipelined/multinow falls back to the client'sdbandtimeoutinstead of the pipeline's. (#1381)himport_preparesnapshots the field names at preparation time, so mutating the strings afterwards no longer changes the schema used for automatic re-preparation. (#1380)ft_aggregatenow sends the rightLOADfield 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 tomultiinside the pipeline, and whenEXECaborts the transaction's command futures hold the error instead of staying unresolved. (#1377) - Only fall back to RESP2 when
HELLOitself fails withNOPROTO, instead of on any command error whose message containsNOPROTO. (#1376) Redis::HashRing#remove_nodefilters the ring positions once instead of once per replica. (#1378)
🧰 Maintenance
- Pin
redis-clientto0.31.0(previously0.30.1). (#1400) - The cluster gem pins
redis-cluster-clientto0.18.0(previously0.16.7): adds the node-by-nodeBLESS SCANroutingbless_scanrelies on, routes the informationalCLUSTER,SCRIPT,MEMORYandCLIENTsubcommands by their command tips instead of rejecting them, followsMOVEDredirections to nodes not yet in the topology, and splits multi-keyunlink,existsandtouchacross slots the waydelalready was. (#1375, #1395) - Document the
himport_auto_prepareclient option. (#1370) - Add CONTRIBUTORS.md. (#1410)
Upgrade notes
zrank/zrevrankwithwith_score: truenow returnnilinstead of[nil, nil]for a missing key or member, andxautoclaimreplies carry an extra'deleted'key; adapt code that destructures those replies.- Cluster users: informational
CLUSTER,SCRIPT,MEMORYandCLIENTsubcommands that the driver used to reject are now routed by their command tips, and multi-keyunlink,existsandtouchno longer need all keys in one slot. - Everything else is drop-in.