Package software.xdev.caching
Class ExpiringLimitedCache<K,V>
java.lang.Object
software.xdev.caching.ExpiringLimitedCache<K,V>
Caches values until
- a specific time (>=1s) elapses (is cleared in batches by a timer so it may stick around a bit longer)
-
expirationTime - a maximum number (>=1) of items is reached -
ExpiringLimitedCache.LimitedLinkedHashMap - the JVM needs memory -
SoftReference)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Map<K,SoftReference<ExpiringLimitedCache.CacheValue<V>>> protected ScheduledExecutorServiceprotected final AtomicIntegerprotected final Objectprotected final ThreadFactoryprotected final Duration -
Constructor Summary
ConstructorsConstructorDescriptionExpiringLimitedCache(String cacheName, Duration expirationTime, int maxSize) -
Method Summary
Modifier and TypeMethodDescriptionintprotected static LocalDateTimeprotected voidvoidvoidsetLogConsumer(Consumer<String> logConsumer) protected void
-
Field Details
-
expirationTime
-
cleanUpExecutorCounter
-
cleanUpExecutorThreadFactory
-
cleanUpExecutor
-
cleanUpExecutorLock
-
logConsumer
-
cache
-
-
Constructor Details
-
ExpiringLimitedCache
-
-
Method Details
-
setLogConsumer
-
log
-
put
-
get
-
shutdownCleanupExecutorIfRequired
protected void shutdownCleanupExecutorIfRequired() -
cacheSize
public int cacheSize() -
currentUtcTime
-