Package org.apache.groovy.json.internal
Class SimpleCache<K,V>
java.lang.Object
org.apache.groovy.json.internal.SimpleCache<K,V>
- Type Parameters:
K- the key typeV- the value type
- All Implemented Interfaces:
Cache<K,V>
Thin adapter that exposes
CommonCache through the internal Cache API.-
Constructor Summary
ConstructorsConstructorDescriptionSimpleCache(int limit) Creates an LRU cache with the supplied size limit.SimpleCache(int limit, CacheType type) Creates a cache with the supplied size limit and eviction policy. -
Method Summary
Modifier and TypeMethodDescriptionRetrieves a value and updates cache state as needed.Retrieves a value using implementation-specific silent access semantics.voidStores a value under the supplied key.voidRemoves the value stored for the supplied key.intsize()Returns the current number of cached entries.toString()Returns the underlying cache state as a string.
-
Constructor Details
-
SimpleCache
Creates a cache with the supplied size limit and eviction policy.- Parameters:
limit- the maximum number of entriestype- the eviction strategy
-
SimpleCache
public SimpleCache(int limit) Creates an LRU cache with the supplied size limit.- Parameters:
limit- the maximum number of entries
-
-
Method Details
-
put
Stores a value under the supplied key. -
get
Retrieves a value and updates cache state as needed. -
getSilent
Retrieves a value using implementation-specific silent access semantics. -
remove
Removes the value stored for the supplied key. -
size
public int size()Returns the current number of cached entries. -
toString
Returns the underlying cache state as a string.
-