Class LRUCache<K,V>

java.lang.Object
org.mockserver.cache.LRUCache<K,V>

public class LRUCache<K,V> extends Object
  • Constructor Details

    • LRUCache

      public LRUCache(MockServerLogger mockServerLogger, int maxSize, long ttlInMillis)
  • Method Details

    • allCachesEnabled

      public static void allCachesEnabled(boolean enabled)
    • clearAllCaches

      public static void clearAllCaches()
    • put

      public void put(K key, V value)
    • put

      public void put(K key, V value, long ttl)
    • getOrCompute

      public V getOrCompute(K key, Function<? super K,? extends V> mappingFunction)
      Atomically returns the value for key, computing and inserting it with mappingFunction if absent. Unlike a get-then-put sequence this is race-free: concurrent callers for the same absent key do not each build their own value and then clobber the cache — the mapping function runs at most once and a single value instance is shared by and returned to all of them (so there are no orphaned instances). Used where the cached value's identity, not just its content, must be stable across threads.
    • get

      public V get(K key)
    • delete

      public void delete(K key)
    • setMaxSizeOverride

      public static void setMaxSizeOverride(int maxSizeOverride)