@Override
            protected boolean removeEldestEntry(final Map.Entry<Bytes, byte[]> eldest) {
                final boolean evict = super.size() > maxCacheSize;
                if (evict && !restoring && listener != null) {
                    listener.apply(eldest.getKey(), eldest.getValue());
                }
                return evict;
            }
An in-memory LRU cache store based on HashSet and HashMap.
streams/src/main/java/org/apache/kafka/streams/state/internals/MemoryLRUCache.java