5.2.0-alpha3
Pre-release
Pre-release
This release provides support for server-assisted, client-side caching, and is currently alpha grade.
Client-side caching is available within UnifiedJedis, JedisPooled, JedisCluster, etc classes via implementation of ClientSideCache class, with RESP3 only. It is recommended a ClientSideCache implementation with TTL (time-to-live). We have included two implementations based on Google Guava and Caffeine libraries.
class CacheExample {
public static void main() {
HostAndPort hnp = HostAndPort.from("localhost:6379");
JedisClientConfig config = DefaultJedisClientConfig.builder()
.resp3() // RESP3 protocol
.password("foobared")
.build();
ClientSideCache csc;
// ClientSideCache csc = GuavaCSC.builder().maximumSize(1000).ttl(100).build();
// ClientSideCache csc = CaffeineCSC.builder().maximumSize(1000).ttl(100).build();
UnifiedJedis client = new UnifiedJedis(hnp, config, csc);
// JedisPooled client = new JedisPooled(hnp, config, csc);
// JedisCluster client = new JedisCluster(Collections.singleton(hnp), config, csc);
client.set("foo", "bar");
client.get("foo");
client.get("foo"); // cache hit
client.del("foo");
client.close();
}
}