void (K key, @NotNull Iterable<? extends V> values) { if (Iterators.isEmpty(values)) { return; } Iterable<V> currentData = myCache.get(key); Collection<V> collection = currentData instanceof Collection? (Collection<V>)currentData : Iterators.collect(currentData, new SmartList<>()); if (!collection.isEmpty()) { boolean changes = false; for (V value : values) { changes |= collection.remove(value); } if (changes) { myCache.invalidate(key); if (collection.isEmpty()) { myDelegate.remove(key); } else { myDelegate.put(key, collection); } } } }