Class Cache<K,V>
java.lang.Object
gw.util.concurrent.Cache<K,V>
- Direct Known Subclasses:
TypeSystemAwareCache
static var MY_CACHE = new Cacheinvalid input: '<'Foo, Bar>( 1000, \ foo -> getBar( foo ) )
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classAConcurrentMapwith a doubly-linked list running through its entries.static interface -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Cache.ConcurrentLinkedHashMap<K, V> private final AtomicIntegerprivate ScheduledFuture<?> private final AtomicIntegerprivate final Cache.MissHandler<K, V> private final Stringprivate final AtomicIntegerprivate final int -
Constructor Summary
ConstructorsConstructorDescriptionCache(String name, int size, Cache.MissHandler<K, V> missHandler) This will create a new cache -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()private voidThis will evict a specific key from the cache.This will get a specific entry, it will call the missHandler if it is not found.intdoubleintgetHits()intintintlogEveryNSeconds(int seconds, ILogger logger) Sets up a recurring task every n seconds to report on the status of this cache.static <K,V> Cache <K, V> make(String name, int size, Cache.MissHandler<K, V> handler) This will put a specific entry in the cachevoidtoString()
-
Field Details
-
_cacheImpl
-
_missHandler
-
_name
-
_size
private final int _size -
_requests
-
_misses
-
_hits
-
_loggingTask
-
-
Constructor Details
-
Cache
This will create a new cache- Parameters:
name- the name of the cache for loggingsize- the maximum size of the logmissHandler- how to handle misses, this is required not to be null
-
-
Method Details
-
clearCacheImpl
private void clearCacheImpl() -
evict
-
put
-
get
-
getConfiguredSize
public int getConfiguredSize() -
getUtilizedSize
public int getUtilizedSize() -
getRequests
public int getRequests() -
getMisses
public int getMisses() -
getHits
public int getHits() -
getHitRate
public double getHitRate() -
logEveryNSeconds
Sets up a recurring task every n seconds to report on the status of this cache. This can be useful if you are doing exploratory caching and wish to monitor the performance of this cache with minimal fuss. Consider- Parameters:
seconds- how often to log the entrylogger- the logger to use- Returns:
- this
-
stopLogging
public void stopLogging() -
clear
public void clear() -
toString
-
make
-