@Override public Map<Class, Map<String, Record>> dump() { Map<String, Record> records = new LinkedHashMap<>(); for (Map.Entry<String, RecordJournal> entry : lruCache.asMap().entrySet()) { records.put(entry.getKey(), entry.getValue().snapshot); } Map<Class, Map<String, Record>> dump = new LinkedHashMap<>(); dump.put(this.getClass(), Collections.unmodifiableMap(records)); if (nextCache().isPresent()) { dump.putAll(nextCache().get().dump()); } return dump; }
@NotNull public Set<String> removeOptimisticUpdates(@NotNull final UUID mutationId) { checkNotNull(mutationId, "mutationId == null"); Set<String> changedCacheKeys = new HashSet<>(); Set<String> removedKeys = new HashSet<>(); Map<String, RecordJournal> recordJournals = lruCache.asMap(); for (Map.Entry<String, RecordJournal> entry : recordJournals.entrySet()) { String cacheKey = entry.getKey(); RecordJournal journal = entry.getValue(); changedCacheKeys.addAll(journal.revert(mutationId)); if (journal.history.isEmpty()) { removedKeys.add(cacheKey); } } lruCache.invalidateAll(removedKeys); return changedCacheKeys; }
@Override public Map<Class, Map<String, Record>> dump() { Map<Class, Map<String, Record>> dump = new LinkedHashMap<>(); dump.put(this.getClass(), Collections.unmodifiableMap(new LinkedHashMap<>(lruCache.asMap()))); if (nextCache().isPresent()) { dump.putAll(nextCache().get().dump()); } return dump; } }
@Override public void clear() { for (Key cachedKey : memCache.asMap().keySet()) { clear(cachedKey); } }
@Override public ConcurrentMap<K, V> asMap() { return delegate().asMap(); }
@Nonnull public Set<String> removeOptimisticUpdates(@Nonnull final UUID mutationId) { checkNotNull(mutationId, "mutationId == null"); Set<String> changedCacheKeys = new HashSet<>(); Set<String> removedKeys = new HashSet<>(); Map<String, RecordJournal> recordJournals = lruCache.asMap(); for (Map.Entry<String, RecordJournal> entry : recordJournals.entrySet()) { String cacheKey = entry.getKey(); RecordJournal journal = entry.getValue(); changedCacheKeys.addAll(journal.revert(mutationId)); if (journal.history.isEmpty()) { removedKeys.add(cacheKey); } } lruCache.invalidateAll(removedKeys); return changedCacheKeys; }
@Nonnull public Set<String> removeOptimisticUpdates(@Nonnull final UUID mutationId) { checkNotNull(mutationId, "mutationId == null"); Set<String> changedCacheKeys = new HashSet<>(); Set<String> removedKeys = new HashSet<>(); Map<String, RecordJournal> recordJournals = lruCache.asMap(); for (Map.Entry<String, RecordJournal> entry : recordJournals.entrySet()) { String cacheKey = entry.getKey(); RecordJournal journal = entry.getValue(); changedCacheKeys.addAll(journal.revert(mutationId)); if (journal.history.isEmpty()) { removedKeys.add(cacheKey); } } lruCache.invalidateAll(removedKeys); return changedCacheKeys; }