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 record
static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Map<K,
SoftReference<ExpiringLimitedCache.CacheValue<V>>> protected ScheduledExecutorService
protected final AtomicInteger
protected final Object
protected final ThreadFactory
protected final Duration
-
Constructor Summary
ConstructorsConstructorDescriptionExpiringLimitedCache
(String cacheName, Duration expirationTime, int maxSize) -
Method Summary
Modifier and TypeMethodDescriptionint
protected static LocalDateTime
protected void
void
void
setLogConsumer
(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
-