Skip to content

5.2.0-alpha2

Pre-release
Pre-release
Compare
Choose a tag to compare
@sazzad16 sazzad16 released this 28 Dec 16:19
· 88 commits to 5.2.0 since this release

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();
    }
}