diff --git a/src/main/java/redis/clients/jedis/JedisCluster.java b/src/main/java/redis/clients/jedis/JedisCluster.java index 423b1682cb..4988b5ee2f 100644 --- a/src/main/java/redis/clients/jedis/JedisCluster.java +++ b/src/main/java/redis/clients/jedis/JedisCluster.java @@ -11,6 +11,8 @@ import redis.clients.jedis.executors.ClusterCommandExecutor; import redis.clients.jedis.providers.ClusterConnectionProvider; import redis.clients.jedis.csc.Cache; +import redis.clients.jedis.csc.CacheConfig; +import redis.clients.jedis.csc.CacheProvider; import redis.clients.jedis.util.JedisClusterCRC16; public class JedisCluster extends UnifiedJedis { @@ -225,10 +227,16 @@ public JedisCluster(Set clusterNodes, JedisClientConfig clientConfi Duration.ofMillis(DEFAULT_MAX_ATTEMPTS * clientConfig.getSocketTimeoutMillis())); } + @Experimental + public JedisCluster(Set hnp, JedisClientConfig jedisClientConfig, CacheConfig cacheConfig) { + this(hnp, jedisClientConfig, new CacheProvider().getCache(cacheConfig)); + } + @Experimental public JedisCluster(Set clusterNodes, JedisClientConfig clientConfig, Cache clientSideCache, int maxAttempts, Duration maxTotalRetriesDuration) { - this(new ClusterConnectionProvider(clusterNodes, clientConfig, clientSideCache), maxAttempts, maxTotalRetriesDuration, + this(new ClusterConnectionProvider(clusterNodes, clientConfig, clientSideCache), maxAttempts, + maxTotalRetriesDuration, clientConfig.getRedisProtocol(), clientSideCache); } diff --git a/src/main/java/redis/clients/jedis/JedisPooled.java b/src/main/java/redis/clients/jedis/JedisPooled.java index 498bcb02c8..7eb67374ae 100644 --- a/src/main/java/redis/clients/jedis/JedisPooled.java +++ b/src/main/java/redis/clients/jedis/JedisPooled.java @@ -9,6 +9,8 @@ import org.apache.commons.pool2.impl.GenericObjectPoolConfig; import redis.clients.jedis.annots.Experimental; import redis.clients.jedis.csc.Cache; +import redis.clients.jedis.csc.CacheConfig; +import redis.clients.jedis.csc.CacheProvider; import redis.clients.jedis.providers.PooledConnectionProvider; import redis.clients.jedis.util.JedisURIHelper; import redis.clients.jedis.util.Pool; @@ -82,6 +84,11 @@ public JedisPooled(final HostAndPort hostAndPort, final JedisClientConfig client super(hostAndPort, clientConfig, clientSideCache); } + @Experimental + public JedisPooled(final HostAndPort hostAndPort, final JedisClientConfig clientConfig, CacheConfig cacheConfig) { + this(hostAndPort, clientConfig, new CacheProvider().getCache(cacheConfig)); + } + public JedisPooled(PooledObjectFactory factory) { this(new PooledConnectionProvider(factory)); } @@ -389,6 +396,12 @@ public JedisPooled(final HostAndPort hostAndPort, final JedisClientConfig client clientConfig.getRedisProtocol(), clientSideCache); } + @Experimental + public JedisPooled(final HostAndPort hostAndPort, final JedisClientConfig clientConfig, CacheConfig cacheConfig, + final GenericObjectPoolConfig poolConfig) { + this(hostAndPort, clientConfig, new CacheProvider().getCache(cacheConfig), poolConfig); + } + public JedisPooled(final GenericObjectPoolConfig poolConfig, final JedisSocketFactory jedisSocketFactory, final JedisClientConfig clientConfig) { super(new PooledConnectionProvider(new ConnectionFactory(jedisSocketFactory, clientConfig), poolConfig), diff --git a/src/main/java/redis/clients/jedis/JedisSentineled.java b/src/main/java/redis/clients/jedis/JedisSentineled.java index 35585f713f..da9eba4baf 100644 --- a/src/main/java/redis/clients/jedis/JedisSentineled.java +++ b/src/main/java/redis/clients/jedis/JedisSentineled.java @@ -4,6 +4,8 @@ import org.apache.commons.pool2.impl.GenericObjectPoolConfig; import redis.clients.jedis.annots.Experimental; import redis.clients.jedis.csc.Cache; +import redis.clients.jedis.csc.CacheConfig; +import redis.clients.jedis.csc.CacheProvider; import redis.clients.jedis.providers.SentineledConnectionProvider; public class JedisSentineled extends UnifiedJedis { @@ -21,6 +23,13 @@ public JedisSentineled(String masterName, final JedisClientConfig masterClientCo sentinels, sentinelClientConfig), masterClientConfig.getRedisProtocol(), clientSideCache); } + @Experimental + public JedisSentineled(String masterName, final JedisClientConfig masterClientConfig, CacheConfig cacheConfig, + Set sentinels, final JedisClientConfig sentinelClientConfig) { + this(masterName, masterClientConfig, new CacheProvider().getCache(cacheConfig), + sentinels, sentinelClientConfig); + } + public JedisSentineled(String masterName, final JedisClientConfig masterClientConfig, final GenericObjectPoolConfig poolConfig, Set sentinels, final JedisClientConfig sentinelClientConfig) { diff --git a/src/main/java/redis/clients/jedis/Protocol.java b/src/main/java/redis/clients/jedis/Protocol.java index f4cd20489a..f8bb5bfb8b 100644 --- a/src/main/java/redis/clients/jedis/Protocol.java +++ b/src/main/java/redis/clients/jedis/Protocol.java @@ -235,10 +235,8 @@ public static void readPushes(final RedisInputStream is, final Cache cache, bool is.readByte(); processPush(is, cache); } - } catch (JedisConnectionException e) { - // TODO handle it properly } catch (IOException e) { - // TODO handle it properly + throw new JedisConnectionException("Failed to read pending buffer for push messages !", e); } } else { while (is.peek(GREATER_THAN_BYTE)) { diff --git a/src/main/java/redis/clients/jedis/UnifiedJedis.java b/src/main/java/redis/clients/jedis/UnifiedJedis.java index e9b01d1426..679cd8eb78 100644 --- a/src/main/java/redis/clients/jedis/UnifiedJedis.java +++ b/src/main/java/redis/clients/jedis/UnifiedJedis.java @@ -20,6 +20,9 @@ import redis.clients.jedis.commands.SampleKeyedCommands; import redis.clients.jedis.commands.RedisModuleCommands; import redis.clients.jedis.csc.Cache; +import redis.clients.jedis.csc.CacheConfig; +import redis.clients.jedis.csc.CacheConnection; +import redis.clients.jedis.csc.CacheProvider; import redis.clients.jedis.exceptions.JedisException; import redis.clients.jedis.executors.*; import redis.clients.jedis.gears.TFunctionListParams; @@ -58,6 +61,7 @@ public class UnifiedJedis implements JedisCommands, JedisBinaryCommands, protected final CommandObjects commandObjects; private final GraphCommandObjects graphCommandObjects; private JedisBroadcastAndRoundRobinConfig broadcastAndRoundRobinConfig = null; + private final Cache cache; public UnifiedJedis() { this(new HostAndPort(Protocol.DEFAULT_HOST, Protocol.DEFAULT_PORT)); @@ -95,9 +99,14 @@ public UnifiedJedis(HostAndPort hostAndPort, JedisClientConfig clientConfig) { } @Experimental - public UnifiedJedis(HostAndPort hostAndPort, JedisClientConfig clientConfig, Cache clientSideCache) { - this(new PooledConnectionProvider(hostAndPort, clientConfig, clientSideCache), clientConfig.getRedisProtocol(), - clientSideCache); + public UnifiedJedis(HostAndPort hostAndPort, JedisClientConfig clientConfig, Cache cache) { + this(new PooledConnectionProvider(hostAndPort, clientConfig, cache), clientConfig.getRedisProtocol(), + cache); + } + + @Experimental + public UnifiedJedis(HostAndPort hostAndPort, JedisClientConfig clientConfig, CacheConfig cacheConfig) { + this(hostAndPort, clientConfig, new CacheProvider().getCache(cacheConfig)); } public UnifiedJedis(ConnectionProvider provider) { @@ -109,8 +118,8 @@ protected UnifiedJedis(ConnectionProvider provider, RedisProtocol protocol) { } @Experimental - protected UnifiedJedis(ConnectionProvider provider, RedisProtocol protocol, Cache clientSideCache) { - this(new DefaultCommandExecutor(provider), provider, new CommandObjects(), protocol, clientSideCache); + protected UnifiedJedis(ConnectionProvider provider, RedisProtocol protocol, Cache cache) { + this(new DefaultCommandExecutor(provider), provider, new CommandObjects(), protocol, cache); } /** @@ -147,6 +156,11 @@ public UnifiedJedis(Connection connection) { if (proto != null) this.commandObjects.setProtocol(proto); this.graphCommandObjects = new GraphCommandObjects(this); + if (connection instanceof CacheConnection) { + this.cache = ((CacheConnection) connection).getCache(); + } else { + this.cache = null; + } } @Deprecated @@ -183,9 +197,9 @@ protected UnifiedJedis(ClusterConnectionProvider provider, int maxAttempts, Dura @Experimental protected UnifiedJedis(ClusterConnectionProvider provider, int maxAttempts, Duration maxTotalRetriesDuration, - RedisProtocol protocol, Cache clientSideCache) { + RedisProtocol protocol, Cache cache) { this(new ClusterCommandExecutor(provider, maxAttempts, maxTotalRetriesDuration), provider, - new ClusterCommandObjects(), protocol, clientSideCache); + new ClusterCommandObjects(), protocol, cache); } /** @@ -259,9 +273,9 @@ private UnifiedJedis(CommandExecutor executor, ConnectionProvider provider, Comm @Experimental private UnifiedJedis(CommandExecutor executor, ConnectionProvider provider, CommandObjects commandObjects, - RedisProtocol protocol, Cache clientSideCache) { + RedisProtocol protocol, Cache cache) { - if (clientSideCache != null && protocol != RedisProtocol.RESP3) { + if (cache != null && protocol != RedisProtocol.RESP3) { throw new IllegalArgumentException("Client-side caching is only supported with RESP3."); } @@ -274,7 +288,7 @@ private UnifiedJedis(CommandExecutor executor, ConnectionProvider provider, Comm this.graphCommandObjects = new GraphCommandObjects(this); this.graphCommandObjects.setBaseCommandArgumentsCreator((comm) -> this.commandObjects.commandArguments(comm)); - + this.cache = cache; } @Override @@ -314,6 +328,10 @@ public void setBroadcastAndRoundRobinConfig(JedisBroadcastAndRoundRobinConfig co this.commandObjects.setBroadcastAndRoundRobinConfig(this.broadcastAndRoundRobinConfig); } + public Cache getCache() { + return cache; + } + public String ping() { return checkAndBroadcastCommand(commandObjects.ping()); } diff --git a/src/main/java/redis/clients/jedis/csc/CacheConfig.java b/src/main/java/redis/clients/jedis/csc/CacheConfig.java new file mode 100644 index 0000000000..2c782a4a7c --- /dev/null +++ b/src/main/java/redis/clients/jedis/csc/CacheConfig.java @@ -0,0 +1,53 @@ +package redis.clients.jedis.csc; + +public class CacheConfig { + + private int maxSize; + private Cacheable cacheable; + private EvictionPolicy evictionPolicy; + + public int getMaxSize() { + return maxSize; + } + + public Cacheable getCacheable() { + return cacheable; + } + + public EvictionPolicy getEvictionPolicy() { + return evictionPolicy; + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + private int maxSize; + private Cacheable cacheable = DefaultCacheable.INSTANCE; + private EvictionPolicy evictionPolicy; + + public Builder maxSize(int maxSize) { + this.maxSize = maxSize; + return this; + } + + public Builder evictionPolicy(EvictionPolicy policy) { + this.evictionPolicy = policy; + return this; + } + + public Builder cacheable(Cacheable cacheable) { + this.cacheable = cacheable; + return this; + } + + public CacheConfig build() { + CacheConfig cacheConfig = new CacheConfig(); + cacheConfig.maxSize = this.maxSize; + cacheConfig.cacheable = this.cacheable; + cacheConfig.evictionPolicy = this.evictionPolicy; + return cacheConfig; + } + } +} \ No newline at end of file diff --git a/src/main/java/redis/clients/jedis/csc/CacheConnection.java b/src/main/java/redis/clients/jedis/csc/CacheConnection.java index 316b0ddd4d..c19dd319ec 100644 --- a/src/main/java/redis/clients/jedis/csc/CacheConnection.java +++ b/src/main/java/redis/clients/jedis/csc/CacheConnection.java @@ -14,16 +14,16 @@ public class CacheConnection extends Connection { - private final Cache clientSideCache; + private final Cache cache; private ReentrantLock lock; - public CacheConnection(final JedisSocketFactory socketFactory, JedisClientConfig clientConfig, Cache clientSideCache) { + public CacheConnection(final JedisSocketFactory socketFactory, JedisClientConfig clientConfig, Cache cache) { super(socketFactory, clientConfig); if (protocol != RedisProtocol.RESP3) { throw new JedisException("Client side caching is only supported with RESP3."); } - this.clientSideCache = Objects.requireNonNull(clientSideCache); + this.cache = Objects.requireNonNull(cache); initializeClientSideCache(); } @@ -37,7 +37,7 @@ protected void initializeFromClientConfig(JedisClientConfig config) { protected Object protocolRead(RedisInputStream inputStream) { lock.lock(); try { - return Protocol.read(inputStream, clientSideCache); + return Protocol.read(inputStream, cache); } finally { lock.unlock(); } @@ -47,7 +47,7 @@ protected Object protocolRead(RedisInputStream inputStream) { protected void protocolReadPushes(RedisInputStream inputStream) { if (lock.tryLock()) { try { - Protocol.readPushes(inputStream, clientSideCache, true); + Protocol.readPushes(inputStream, cache, true); } finally { lock.unlock(); } @@ -57,37 +57,41 @@ protected void protocolReadPushes(RedisInputStream inputStream) { @Override public void disconnect() { super.disconnect(); - clientSideCache.flush(); + cache.flush(); } @Override public T executeCommand(final CommandObject commandObject) { final CacheKey cacheKey = new CacheKey(commandObject); - if (!clientSideCache.isCacheable(cacheKey)) { - clientSideCache.getStats().nonCacheable(); + if (!cache.isCacheable(cacheKey)) { + cache.getStats().nonCacheable(); return super.executeCommand(commandObject); } - CacheEntry cacheEntry = clientSideCache.get(cacheKey); + CacheEntry cacheEntry = cache.get(cacheKey); if (cacheEntry != null) { // (probable) CACHE HIT !! cacheEntry = validateEntry(cacheEntry); if (cacheEntry != null) { // CACHE HIT confirmed !!! - clientSideCache.getStats().hit(); + cache.getStats().hit(); return cacheEntry.getValue(); } } // CACHE MISS !! - clientSideCache.getStats().miss(); + cache.getStats().miss(); T value = super.executeCommand(commandObject); cacheEntry = new CacheEntry<>(cacheKey, value, this); - clientSideCache.set(cacheKey, cacheEntry); + cache.set(cacheKey, cacheEntry); // this line actually provides a deep copy of cached object instance value = cacheEntry.getValue(); return value; } + public Cache getCache() { + return cache; + } + private void initializeClientSideCache() { sendCommand(Protocol.Command.CLIENT, "TRACKING", "ON"); String reply = getStatusCodeReply(); @@ -99,17 +103,17 @@ private void initializeClientSideCache() { private CacheEntry validateEntry(CacheEntry cacheEntry) { CacheConnection cacheOwner = cacheEntry.getConnection(); if (cacheOwner == null || cacheOwner.isBroken() || !cacheOwner.isConnected()) { - clientSideCache.delete(cacheEntry.getCacheKey()); + cache.delete(cacheEntry.getCacheKey()); return null; } else { try { cacheOwner.readPushesWithCheckingBroken(); } catch (JedisException e) { - clientSideCache.delete(cacheEntry.getCacheKey()); + cache.delete(cacheEntry.getCacheKey()); return null; } - return clientSideCache.get(cacheEntry.getCacheKey()); + return cache.get(cacheEntry.getCacheKey()); } } } diff --git a/src/main/java/redis/clients/jedis/csc/CacheProvider.java b/src/main/java/redis/clients/jedis/csc/CacheProvider.java new file mode 100644 index 0000000000..774f772c49 --- /dev/null +++ b/src/main/java/redis/clients/jedis/csc/CacheProvider.java @@ -0,0 +1,23 @@ +package redis.clients.jedis.csc; + +import java.util.HashMap; + +public class CacheProvider { + + public Cache getCache(CacheConfig config) { + return getCache(config, new HashMap()); + } + + public Cache getCache(CacheConfig config, HashMap map) { + return new DefaultCache(config.getMaxSize(), map, config.getCacheable(), + getEvictionPolicy(config)); + } + + private EvictionPolicy getEvictionPolicy(CacheConfig config) { + if (config.getEvictionPolicy() == null) { + // It will be default to LRUEviction, until we have other eviction implementations + return new LRUEviction(config.getMaxSize()); + } + return config.getEvictionPolicy(); + } +} \ No newline at end of file diff --git a/src/main/java/redis/clients/jedis/csc/DefaultCache.java b/src/main/java/redis/clients/jedis/csc/DefaultCache.java index aee3c634b5..ea561359eb 100644 --- a/src/main/java/redis/clients/jedis/csc/DefaultCache.java +++ b/src/main/java/redis/clients/jedis/csc/DefaultCache.java @@ -9,19 +9,19 @@ public class DefaultCache extends AbstractCache { protected final Map cache; private final EvictionPolicy evictionPolicy; - public DefaultCache(int maximumSize) { + protected DefaultCache(int maximumSize) { this(maximumSize, new HashMap()); } - public DefaultCache(int maximumSize, Map map) { + protected DefaultCache(int maximumSize, Map map) { this(maximumSize, map, DefaultCacheable.INSTANCE, new LRUEviction(maximumSize)); } - public DefaultCache(int maximumSize, Cacheable cacheable) { + protected DefaultCache(int maximumSize, Cacheable cacheable) { this(maximumSize, new HashMap(), cacheable, new LRUEviction(maximumSize)); } - public DefaultCache(int maximumSize, Map map, Cacheable cacheable, EvictionPolicy evictionPolicy) { + protected DefaultCache(int maximumSize, Map map, Cacheable cacheable, EvictionPolicy evictionPolicy) { super(maximumSize, cacheable); this.cache = map; this.evictionPolicy = evictionPolicy; diff --git a/src/test/java/redis/clients/jedis/csc/ClientSideCacheFunctionalityTest.java b/src/test/java/redis/clients/jedis/csc/ClientSideCacheFunctionalityTest.java index ab5ac2761b..0d171df89c 100644 --- a/src/test/java/redis/clients/jedis/csc/ClientSideCacheFunctionalityTest.java +++ b/src/test/java/redis/clients/jedis/csc/ClientSideCacheFunctionalityTest.java @@ -259,7 +259,6 @@ public void testInvalidationWithUnifiedJedis() { //invalidating the cache and read it back from server Assert.assertEquals("bar2", client.get("foo")); - // ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(GuavaClientSideCache.class); Mockito.verify(mock, Mockito.times(1)).deleteByRedisKeys(Mockito.anyList()); Mockito.verify(mock, Mockito.times(2)).set(Mockito.any(CacheKey.class), Mockito.any(CacheEntry.class)); } finally { @@ -305,7 +304,8 @@ public void testSequentialAccess() throws InterruptedException { ReentrantLock lock = new ReentrantLock(true); ExecutorService executorService = Executors.newFixedThreadPool(threadCount); - try (JedisPooled jedis = new JedisPooled(endpoint.getHostAndPort(), clientConfig.get(), new TestCache())) { + CacheConfig cacheConfig = CacheConfig.builder().maxSize(1000).build(); + try (JedisPooled jedis = new JedisPooled(endpoint.getHostAndPort(), clientConfig.get(), cacheConfig)) { // Submit multiple threads to perform concurrent operations CountDownLatch latch = new CountDownLatch(threadCount); for (int i = 0; i < threadCount; i++) { diff --git a/src/test/java/redis/clients/jedis/csc/JedisClusterClientSideCacheTest.java b/src/test/java/redis/clients/jedis/csc/JedisClusterClientSideCacheTest.java index aca94a545c..a5823dea56 100644 --- a/src/test/java/redis/clients/jedis/csc/JedisClusterClientSideCacheTest.java +++ b/src/test/java/redis/clients/jedis/csc/JedisClusterClientSideCacheTest.java @@ -38,4 +38,9 @@ protected JedisCluster createCachedJedis(Cache cache) { return new JedisCluster(hnp, clientConfig.get(), cache); } + @Override + protected JedisCluster createCachedJedis(CacheConfig cacheConfig) { + return new JedisCluster(hnp, clientConfig.get(), cacheConfig); + } + } diff --git a/src/test/java/redis/clients/jedis/csc/JedisPooledClientSideCacheTestBase.java b/src/test/java/redis/clients/jedis/csc/JedisPooledClientSideCacheTestBase.java index 7becbe74d3..e86ef936af 100644 --- a/src/test/java/redis/clients/jedis/csc/JedisPooledClientSideCacheTestBase.java +++ b/src/test/java/redis/clients/jedis/csc/JedisPooledClientSideCacheTestBase.java @@ -25,6 +25,11 @@ protected JedisPooled createCachedJedis(Cache cache) { return new JedisPooled(endpoint.getHostAndPort(), endpoint.getClientConfigBuilder().resp3().build(), cache); } + @Override + protected JedisPooled createCachedJedis(CacheConfig cacheConfig) { + return new JedisPooled(endpoint.getHostAndPort(), endpoint.getClientConfigBuilder().resp3().build(), cacheConfig); + } + @Test public void clearIfOneDiesTest() { Cache cache = new TestCache(); diff --git a/src/test/java/redis/clients/jedis/csc/JedisSentineledClientSideCacheTest.java b/src/test/java/redis/clients/jedis/csc/JedisSentineledClientSideCacheTest.java index 578ed6a316..e81ec6e90f 100644 --- a/src/test/java/redis/clients/jedis/csc/JedisSentineledClientSideCacheTest.java +++ b/src/test/java/redis/clients/jedis/csc/JedisSentineledClientSideCacheTest.java @@ -33,4 +33,9 @@ protected JedisSentineled createCachedJedis(Cache cache) { return new JedisSentineled(MASTER_NAME, masterClientConfig, cache, sentinels, sentinelClientConfig); } + @Override + protected JedisSentineled createCachedJedis(CacheConfig cacheConfig) { + return new JedisSentineled(MASTER_NAME, masterClientConfig, cacheConfig, sentinels, sentinelClientConfig); + } + } diff --git a/src/test/java/redis/clients/jedis/csc/TestCache.java b/src/test/java/redis/clients/jedis/csc/TestCache.java index ebebe03051..c4ea43a9e7 100644 --- a/src/test/java/redis/clients/jedis/csc/TestCache.java +++ b/src/test/java/redis/clients/jedis/csc/TestCache.java @@ -17,13 +17,13 @@ public TestCache(Map map, Cacheable cacheable) { super(10000, map, cacheable, new LRUEviction(10000)); } - public TestCache(int maxSize, Map map, Cacheable cacheable) { - this(maxSize, map, cacheable, new LRUEviction(maxSize)); + public TestCache(int maximumSize, Map map, Cacheable cacheable) { + this(maximumSize, map, cacheable, new LRUEviction(maximumSize)); } - public TestCache(int maxSize, Map map, Cacheable cacheable, + public TestCache(int maximumSize, Map map, Cacheable cacheable, EvictionPolicy evictionPolicy) { - super(maxSize, map, cacheable, evictionPolicy); + super(maximumSize, map, cacheable, evictionPolicy); } } diff --git a/src/test/java/redis/clients/jedis/csc/UnifiedJedisClientSideCacheTestBase.java b/src/test/java/redis/clients/jedis/csc/UnifiedJedisClientSideCacheTestBase.java index 771e08d5df..9d512e755e 100644 --- a/src/test/java/redis/clients/jedis/csc/UnifiedJedisClientSideCacheTestBase.java +++ b/src/test/java/redis/clients/jedis/csc/UnifiedJedisClientSideCacheTestBase.java @@ -24,6 +24,8 @@ public abstract class UnifiedJedisClientSideCacheTestBase { protected abstract UnifiedJedis createCachedJedis(Cache cache); + protected abstract UnifiedJedis createCachedJedis(CacheConfig cacheConfig); + @Before public void setUp() throws Exception { control = createRegularJedis(); @@ -37,7 +39,8 @@ public void tearDown() throws Exception { @Test public void simple() { - try (UnifiedJedis jedis = createCachedJedis(new TestCache())) { + CacheConfig cacheConfig = CacheConfig.builder().maxSize(1000).build(); + try (UnifiedJedis jedis = createCachedJedis(cacheConfig)) { control.set("foo", "bar"); assertEquals("bar", jedis.get("foo")); control.del("foo"); @@ -64,7 +67,8 @@ public void simpleWithSimpleMap() { @Test public void flushAll() { - try (UnifiedJedis jedis = createCachedJedis(new TestCache())) { + CacheConfig cacheConfig = CacheConfig.builder().maxSize(1000).build(); + try (UnifiedJedis jedis = createCachedJedis(cacheConfig)) { control.set("foo", "bar"); assertEquals("bar", jedis.get("foo")); control.flushAll();