@Override public Stream<String> keyStream() { // don't return a keySet stream directly as it may // throw ConcurrentModificationException if there are concurrent writes List<String> keys = new ArrayList<>(map.keySet()); return keys.stream(); }
@Override public Stream<String> keyStream(String prefix) { // don't return a keySet stream directly as it may // throw ConcurrentModificationException if there are concurrent writes List<String> keys = new ArrayList<>(); map.keySet().stream().filter(key -> key.startsWith(prefix)).forEach(keys::add); return keys.stream(); }
private void scanEntries() { for (String key : cache.keySet()) { CachedValueWrapper wrapper = cache.get(key); if (wrapper.getRedisCacheAnn().redisFor() == StoreValue) continue; long expiration = RedisCacheUtils.redisExpirationSeconds(key, appContext); long cacheExpiration = cache.getExpiration(key); if (expiration == cacheExpiration) continue; CachedValueWrapper removed = cache.remove(key); if (removed == null) continue; Logger logger = wrapper.getLogger(); logger.debug("invalidate cache {} because of redis refresh seconds changed to {} ", key, expiration); } }