RedisCacheStore implements CacheStore { @Override public boolean delete(String... keys) { try { long deletedKeys = redis.del(keys); return deletedKeys > 0; } catch (UncheckedIOException | RedisException e) { logger.warn(errorCode("CACHE_STORE_FAILED"), "failed to connect to redis, error={}", e.getMessage(), e); return false; } } RedisCacheStore(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);  }
@Test void delete() { when(redis.del("key1", "key2")).thenReturn(2L); assertThat(cacheStore.delete("key1", "key2")).isTrue(); when(redis.del("key3")).thenReturn(0L); assertThat(cacheStore.delete("key3")).isFalse(); }
@Test void deleteWithFailure() { when(redis.del("key")).thenThrow(new RedisException("unexpected")); assertThat(cacheStore.delete("key")).isFalse(); }