Package org.mockserver.cache
Class LRUCache<K,V>
java.lang.Object
org.mockserver.cache.LRUCache<K,V>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidallCachesEnabled(boolean enabled) static voidvoidgetOrCompute(K key, Function<? super K, ? extends V> mappingFunction) Atomically returns the value forkey, computing and inserting it withmappingFunctionif absent.voidvoidstatic voidsetMaxSizeOverride(int maxSizeOverride)
-
Constructor Details
-
LRUCache
-
-
Method Details
-
allCachesEnabled
public static void allCachesEnabled(boolean enabled) -
clearAllCaches
public static void clearAllCaches() -
put
-
put
-
getOrCompute
Atomically returns the value forkey, computing and inserting it withmappingFunctionif absent. Unlike aget-then-putsequence 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
-
delete
-
setMaxSizeOverride
public static void setMaxSizeOverride(int maxSizeOverride)
-