RedisLocalCacheStore implements CacheStore { @Override public <T> void put(String key, T value, Duration expiration, CacheContext<T> context) { localCache.put(key, value, expiration, context); redisCache.put(key, value, expiration, context); publishInvalidateLocalCacheMessage(List.of(key)); } RedisLocalCacheStore(CacheStore localCache, CacheStore redisCache, RedisImpl redis); @Override T get(String key, CacheContext<T> context); @Override Map<String, T> getAll(String[] keys, CacheContext<T> context); @Override void put(String key, T value, Duration expiration, CacheContext<T> context); @Override void putAll(List<Entry<T>> values, Duration expiration, CacheContext<T> context); @Override boolean delete(String... keys); static final String CHANNEL_INVALIDATE_CACHE; }
@Test void put() { var value = new TestCache(); cacheStore.put("key", value, Duration.ofHours(1), null); verify(localCacheStore).put("key", value, Duration.ofHours(1), null); verify(redisCacheStore).put("key", value, Duration.ofHours(1), null); verify(redis).publish(eq(CHANNEL_INVALIDATE_CACHE), any()); }