Package io.github.dhruv1110.jcachex.impl
Class OptimizedCache<K,V>
- java.lang.Object
-
- io.github.dhruv1110.jcachex.impl.base.AbstractCacheBase<K,V>
-
- io.github.dhruv1110.jcachex.impl.base.DataBackedCacheBase<K,V,CacheEntry<V>>
-
- io.github.dhruv1110.jcachex.impl.base.ConcurrentCacheBase<K,V>
-
- io.github.dhruv1110.jcachex.impl.base.OptimizedCacheBase<K,V>
-
- io.github.dhruv1110.jcachex.impl.OptimizedCache<K,V>
-
- Type Parameters:
K
- the type of keysV
- the type of values
- All Implemented Interfaces:
Cache<K,V>
public class OptimizedCache<K,V> extends OptimizedCacheBase<K,V>
High-performance cache implementation with Caffeine-inspired optimizations.This implementation provides:
- Lock-Free Reads: Uses atomic operations and access buffers
- Window TinyLFU: Advanced eviction with frequency-based admission control
- Batched Operations: Reduces contention through batch processing
- Adaptive Sizing: Automatically adjusts to workload patterns
- Since:
- 1.0.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class io.github.dhruv1110.jcachex.impl.base.OptimizedCacheBase
OptimizedCacheBase.State
-
-
Field Summary
-
Fields inherited from class io.github.dhruv1110.jcachex.impl.base.OptimizedCacheBase
accessBuffer, DEFAULT_DRAIN_INTERVAL_NANOS, DEFAULT_DRAIN_THRESHOLD, FREQUENCY_SKETCH_SIZE, frequencySketch, maintenanceLock, operationState, version, windowTinyLFUStrategy
-
Fields inherited from class io.github.dhruv1110.jcachex.impl.base.ConcurrentCacheBase
currentSize, currentWeight, evictionStrategy, scheduler, STRIPE_COUNT, stripes
-
Fields inherited from class io.github.dhruv1110.jcachex.impl.base.DataBackedCacheBase
data
-
Fields inherited from class io.github.dhruv1110.jcachex.impl.base.AbstractCacheBase
config, hasExpiration, hasMaximumSize, hasMaximumWeight, hitCount, maximumSize, missCount, stats, statsEnabled
-
-
Constructor Summary
Constructors Constructor Description OptimizedCache(CacheConfig<K,V> config)
Creates a new optimized cache with the specified configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getDetailedMetrics()
Returns detailed performance metrics for the optimized cache.protected void
performCustomOptimization()
Performs custom optimization specific to OptimizedCache.-
Methods inherited from class io.github.dhruv1110.jcachex.impl.base.OptimizedCacheBase
doClear, doGet, doPut, drainAccessBuffer, enforceSize, getOperationState, getPerformanceMetrics, getVersion, performPeriodicMaintenance, processAccessRecord, recordAccess, scheduleEviction, scheduleOptimizationTasks, shouldAvoidEvictingNewEntries, shutdown
-
Methods inherited from class io.github.dhruv1110.jcachex.impl.base.ConcurrentCacheBase
cleanupExpiredEntries, createCacheEntry, createCacheEntry, doContainsKey, doRemove, evictEntries, evictEntries, extractValue, getCurrentWeight, getReadLock, getStripeIndex, getWriteLock, isValidEntry, loadValue, notifyListeners, recordScheduledTask, refreshEntries, scheduleCleanup, scheduleRefresh, size
-
Methods inherited from class io.github.dhruv1110.jcachex.impl.base.DataBackedCacheBase
afterClear, beforeClear, createMapEntry, entries, getDataMap, isValidValue, keys, values
-
Methods inherited from class io.github.dhruv1110.jcachex.impl.base.AbstractCacheBase
clear, clearAsync, config, containsKey, get, getAsync, isEntryExpired, isSizeLimitReached, put, putAsync, recordClearStatistics, recordGetStatistics, recordPutStatistics, recordRemoveStatistics, remove, removeAsync, stats, updateStatsFromCounters, validateKey, validateValue
-
-
-
-
Constructor Detail
-
OptimizedCache
public OptimizedCache(CacheConfig<K,V> config)
Creates a new optimized cache with the specified configuration.- Parameters:
config
- the cache configuration
-
-
Method Detail
-
performCustomOptimization
protected void performCustomOptimization()
Performs custom optimization specific to OptimizedCache.- Overrides:
performCustomOptimization
in classOptimizedCacheBase<K,V>
-
getDetailedMetrics
public String getDetailedMetrics()
Returns detailed performance metrics for the optimized cache.
-
-