RedisLocalCacheStore implements CacheStore { @Override public <T> void putAll(List<Entry<T>> values, Duration expiration, CacheContext<T> context) { localCache.putAll(values, expiration, context); redisCache.putAll(values, expiration, context); publishInvalidateLocalCacheMessage(keys(values)); } 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 putAll() { List<CacheStore.Entry<TestCache>> values = List.of(new CacheStore.Entry<>("key", new TestCache())); Duration expiration = Duration.ofHours(1); cacheStore.putAll(values, expiration, null); verify(localCacheStore).putAll(values, expiration, null); verify(redisCacheStore).putAll(values, expiration, null); verify(redis).publish(eq(CHANNEL_INVALIDATE_CACHE), any()); }