Skip to content

Jedis 8.1.0 Release Notes

This guide helps you upgrade from Jedis 8.0.0.

Unreleased

Jedis 8.1.0 has not been released yet. These notes track changes on master since 8.0.0 and are updated as changes merge; remove this notice when 8.1.0 ships.

Note

If your change alters user-visible behavior, add an entry here in the same PR.

Highlights

Smart Client Handoffs (#4668)

Jedis now reacts to server maintenance push notifications with relaxed timeouts and pre-handoffs. The feature requires RESP3 and is configured with MaintenanceNotificationsConfig via RedisClient.builder().maintenanceNotifications(...). It is enabled by default (Mode.AUTO) on RESP3 connections; pass MaintenanceNotificationsConfig.DISABLED to opt out. See the Smart Client Handoffs guide.

Count-Min Sketch cell size and negative increments

cmsInitByDim and cmsInitByProb gain overloads with a trailing CmsCellSize enum (ONE_BYTE, TWO_BYTES, FOUR_BYTES, EIGHT_BYTES), mapping to the new CELL_SIZE option of CMS.INITBYDIM / CMS.INITBYPROB (Redis 8.12). Smaller cells cut memory for short-lived counters; 8-byte cells allow very large totals. cmsInfo now also returns the cell_size entry on servers that support it, and cmsIncrBy accepts negative increments. Redis 8.12 checks each item of CMS.INCRBY separately and rejects an increment that would overflow the cell or drop a count below zero. Both cmsIncrBy overloads surface such a rejection as a JedisDataException (CMS: INCRBY overflow / CMS: INCRBY underflow); in pipelines it is raised by Response.get(). Items the server accepted in the same call stay applied. Older servers do not emit these per-item errors; they reject the CELL_SIZE option and negative increments with a server error.

Smart Client Handoffs for Redis Cluster (#4732)

RedisClusterClient now reacts to the cluster maintenance notifications SMIGRATING and SMIGRATED: timeouts are relaxed client-wide while a slot migration is in progress, and the completed migration is applied to the slot table in place — no CLUSTER SLOTS refresh and no MOVED round trip — with the pool of a node left without slots removed afterwards. The same MaintenanceNotificationsConfig is configured via RedisClusterClient.builder().maintenanceNotifications(...) and, as for RedisClient, defaults to Mode.AUTO on RESP3. See the Redis Cluster section of the guide.

Capacity hints for collection-built commands (#4737)

CommandArguments gained ensureCapacity(int), a chainable hint that pre-sizes the backing argument list for the expected total number of arguments (command token included — the RESP array length of the final command):

CommandArguments args = new CommandArguments(ZADD)
    .ensureCapacity(2 + 2 * members.size()) // command + key + member/score pairs
    .key(key);

This avoids repeated ArrayList growth copies when large commands are built directly, e.g. via executeCommand. Under-estimating falls back to normal growth, so correctness never depends on the estimate. The typed API benefits automatically: collection-built commands (MSET, map HSET/HMSET, ZADD, GEOADD, XADD, addObjects(...)) now pre-size internally from the known collection size.

BLESS: protect keys from eviction

Redis 8.12 adds the BLESS command family, which flags individual keys so they are never chosen as maxmemory eviction victims. Jedis exposes it on every client surface (UnifiedJedis, pipelines, transactions and the legacy Jedis), for both String and byte[] keys:

jedis.blessSet("session:alice", BlessFlag.NO_EVICT);   // 1 = flag turned on, 0 = already on
jedis.blessGet("session:alice");                       // [BlessFlag.NO_EVICT], empty when unblessed
jedis.blessScan("0", BlessFlag.NO_EVICT, 100);         // SCAN-style cursor over blessed keys
jedis.blessClear("session:alice", BlessFlag.NO_EVICT); // 1 = flag turned off, 0 = already off

BlessFlag.NO_EVICT is the only flag the server defines today; BlessFlag.of("TOKEN") forwards any future flag and lets the server validate it. Tokens are upper-cased, matching the server's case-insensitive handling, so BlessFlag.of("no-evict") equals BlessFlag.NO_EVICT. blessGet returns List<BlessFlag> built the same way, so blessGet(key).contains(BlessFlag.NO_EVICT) works for any server spelling; the byte[] overload returns the raw tokens.

BLESS SCAN only iterates the node that receives it, so RedisClusterClient rejects blessScan with UnsupportedOperationException; use blessScanIteration(batchCount, flag) instead, which runs an independent cursor on every node. The instance-wide number of blessed keys is the blessed_keys field of INFO stats. Servers older than 8.12 reply with an unknown-command error.

API Additions

Vector set plain overloads (#4693)

Parameter-free overloads for the experimental vector-set methods that previously required null params: vadd/vaddFP32 with reduceDim, and the vsim*WithScores and vsim*WithScoresAndAttribs variants, across the String, binary, and pipeline APIs.

BITRANGEINTARRAY

New bitrangeintarray methods return the offsets of the set bits in a range of a bitmap, or of the clear bits with BitRangeIntArrayParams.zeros(), as List<Long>, across the String, binary, and pipeline APIs (Redis 8.12). BitRangeIntArrayParams also sets the unit of the range (BYTE or BIT) and a LIMIT on the number of offsets. To page through a bitmap in BIT units, start the next call at the last returned offset + 1; a page shorter than the limit is the last one.

Set member expiration commands

Redis 8.12 adds per-member expiration to sets. Jedis exposes the ten commands with the same shape as the hash field expiration methods: sexpire, spexpire, sexpireAt, spexpireAt (each with an optional ExpiryOption condition), sttl, spttl, sexpireTime, spexpireTime, spersist, and saddex(key, SAddExParams, members...) with mnx()/mxx() and ex/px/exAt/pxAt/keepTtl. Every method also has a single-member overload, so a caller with one member needs no array at all and, for the per-member commands, gets the member's code back as a plain long. Available on the String and binary APIs, in pipelines and transactions, and on Jedis. On servers older than 8.12 the commands fail with the server's unknown-command error. The existing Jedis set methods are unchanged; note that on Redis 8.12 sunionstore keeps the farthest member expiration, sinterstore the nearest, sdiffstore the first set's, and smove moves the member together with its expiration.

Behavior Changes

Changes that may affect existing applications even though they are not breaking API changes.

MSETEX requires keys in one hash slot (#4806)

RedisClusterClient.msetex() now rejects keys from different hash slots with JedisClusterOperationException before any writes. This applies to both String and binary overloads, with or without NX/XX.

Previously, the client split the call by slot, allowing partial writes and a misleading Boolean result when a condition succeeded in one slot and failed in another. A single request preserves atomicity: true means all keys were set, and false means none were set. This deliberately overrides the server's request_policy:multi_shard hint for this API.

Action required: callers using keys from different slots must place the keys in one slot, for example with a shared hash tag such as {user:42}:name and {user:42}:session.

Cluster clients attempt the maintenance-notifications handshake by default (#4732)

On RESP3, every connection opened by RedisClusterClient now sends CLIENT MAINT_NOTIFICATIONS ON during setup (Mode.AUTO). Servers that reject the command are unaffected: the feature is quietly disabled for that connection and no error is raised. RESP2 connections are not affected.

Action required: none for typical applications. To skip the handshake entirely, pass MaintenanceNotificationsConfig.DISABLED to RedisClusterClient.builder().maintenanceNotifications(...).

Closing a client no longer stops its AuthXManager

An AuthXManager is created by the application and passed in through JedisClientConfig, so its lifecycle now belongs to the application, like the config itself. Previously ConnectionPool.close() stopped the manager unconditionally, which broke every other user of a shared manager: after a Sentinel master failover the new master pool was left without token renewal, and closing one of several clients built on the same manager stopped renewal for the rest. Cluster and multi-db clients, on the other hand, never stopped it. All clients now behave the same and leave the manager running.

Closed and destroyed pools are also properly unregistered from the manager. Previously the unregistration silently failed, so a stale pool kept receiving post-authentication callbacks and made the token manager's renewal cycle fail on its closed pool.

Action required: call authXManager.stop() after closing the last client that uses it. Applications that relied on RedisClient.close(), JedisPooled.close() or RedisSentinelClient.close() to stop the manager will otherwise keep its renewal threads alive.

Key pre-processor applied to all key arguments (#4675)

The source key of ZRANGESTORE/GEOSEARCHSTORE and the script KEYS passed to eval(script, keyCount, ...) / evalsha(sha1, keyCount, ...) were previously not treated as keys: a configured CommandKeyArgumentPreProcessor (e.g. key prefixing) did not transform them, and the store commands' source key was invisible to cluster key routing. They are now handled like every other key argument: the pre-processor applies to them, and on cluster a cross-slot ZRANGESTORE/GEOSEARCHSTORE fails client-side with JedisClusterOperationException instead of the server's CROSSSLOT error.

Action required: remove any manual prefixing workaround for these arguments (they would now be prefixed twice), and update catch blocks that matched the server CROSSSLOT JedisDataException for these commands.

Pub/sub push messages are no longer delivered as command replies outside a subscription (#4701)

On RESP3, a pub/sub push frame that arrived while no pub/sub read loop was running — for example a message the server delivered after the UNSUBSCRIBE confirmation, as can happen behind the Redis Enterprise proxy — was returned as the next command's reply. This desynced the reply stream and typically surfaced as ClassCastException: java.util.ArrayList cannot be cast to [B.

Such stray pub/sub pushes are now logged at debug level and dropped instead of being delivered to the application, and the following command receives its own reply. Behavior during an active subscribe/psubscribe/ssubscribe loop is unchanged. Custom PushConsumers registered on a connection now also observe pub/sub-typed pushes received outside a subscription, which the built-in consumer previously propagated before they could see them; the public PUBSUB_CONSUMER constant is unchanged and still propagates unconditionally.

Action required: none for typical applications. Code that relied on reading raw pub/sub frames from a connection without going through the JedisPubSub/ JedisShardedPubSub loops (e.g. hand-rolled sendCommand(SUBSCRIBE) + getUnflushedObject()) will no longer receive those frames; use the pub/sub APIs or register a custom PushConsumer that propagates them.

Pipeline sync() reports read failures to the caller (#4761)

Before: if a node's connection failed while ClusterPipeline.sync() was reading replies, the error was only logged. sync() returned normally, Response.get() for that node threw IllegalStateException: Please close pipeline or multi block before calling this method, and the next command routed to the node, or close(), could throw NullPointerException. Single-node Pipeline.sync() threw the error, but left its responses unset in the same way.

Now, on both pipelines:

  • sync() and close() rethrow the failure unchanged. A cluster pipeline still reads every other node first; if several nodes fail, the first in pipeline order is thrown and the others are attached as suppressed.
  • Each response whose reply was lost rethrows the failure from get(): a JedisException (such as JedisConnectionException) as is, anything else as the cause of a JedisException.
  • A cluster pipeline drops the failed nodes, so it can be closed or reused; the next command for such a node takes a fresh connection. A single-node pipeline's connection is broken after a failed sync(), so close it.

The pipeline does not refresh the slot cache: after a failover, a reused cluster pipeline keeps routing to the old address until the topology is refreshed elsewhere.

Action required: handle exceptions from ClusterPipeline.sync()/close(), which previously returned normally after a failed read. Don't re-send a failed pipeline blindly: the server may already have applied some of its commands.

ClusterPipeline and JedisCluster apply the config's command settings (#4813)

new ClusterPipeline(nodes, config, ...) and the deprecated new JedisCluster(nodes, config, ...), including its pipelines, ignored the config's commandKeyArgumentPreProcessor, jsonObjectMapper and searchDialect. They now apply them like RedisClusterClient.

Action required: drop any manual key prefixing or JSON serialisation that worked around this; it would now apply twice.

monitor no longer returns a monitoring connection to the pool

A JedisMonitor.onCommand that threw left the connection in MONITOR mode with an infinite read timeout, and Jedis.close() returned it to JedisPool. The next borrower read the queued MONITOR lines as its replies, so get could return another client's command and its arguments. The connection is now marked broken when monitor exits, and the pool destroys it.

Action required: none for pooled clients. Replace a non-pooled Jedis after monitor exits: further commands on it fail with JedisConnectionException.

Deprecations

  • CacheEntry(CacheKey, value, connection) (#4779), with no replacement: cache entries are created by Jedis.