@NotNull public Set<String> mergeOptimisticUpdate(@NotNull final Record record) { checkNotNull(record, "record == null"); final RecordJournal journal = lruCache.getIfPresent(record.key()); if (journal == null) { lruCache.put(record.key(), new RecordJournal(record)); return Collections.singleton(record.key()); } else { return journal.commit(record); } }
@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; }
@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; }
@Nonnull public Set<String> mergeOptimisticUpdate(@Nonnull final Record record) { checkNotNull(record, "record == null"); final RecordJournal journal = lruCache.getIfPresent(record.key()); if (journal == null) { lruCache.put(record.key(), new RecordJournal(record)); return Collections.singleton(record.key()); } else { return journal.commit(record); } }
@Nonnull public Set<String> mergeOptimisticUpdate(@Nonnull final Record record) { checkNotNull(record, "record == null"); final RecordJournal journal = lruCache.getIfPresent(record.key()); if (journal == null) { lruCache.put(record.key(), new RecordJournal(record)); return Collections.singleton(record.key()); } else { return journal.commit(record); } }