github redis/jedis v5.2.0-alpha2
5.2.0-alpha2

latest releases: v5.2.0-beta5, v5.1.5, v5.1.4...
pre-release9 months ago

This release provides support for server-assisted, client-side caching, and is currently alpha grade. Currently it is supported on top of the Jedis class, and will be merged to Jedis/UnifiedJedis classes via configuration parameters.

Client-side caching is available through JedisClientSideCache class, with RESP3 only.

Note: The process of ensuring the last invalidation when there is none, is still time consuming; it is suggested to use a smaller socket timeout if this is an issue. We have started with only GET command at this moment.

import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisClientConfig;
import redis.clients.jedis.DefaultJedisClientConfig;
import redis.clients.jedis.JedisClientSideCache;

class CacheExample {
    public static void main() {
        HostAndPort hnp = HostAndPort.from("localhost:6379");
        JedisClientConfig config = DefaultJedisClientConfig.builder()
                                            .resp3()                    // RESP3 protocol
                                            .socketTimeoutMillis(20)    // smaller socket timeout
                                            .password("foobared")
                                            .build();

        JedisClientSideCache jCache = new JedisClientSideCache(hnp, config);

        jCache.set("foo", "bar");
        jCache.get("foo");
        jCache.get("foo");      // cache hit
        jCache.del("foo");

        jCache.close();
    }
}

Don't miss a new jedis release

NewReleases is sending notifications on new releases.