Class DefaultCache<K,​V>

  • Type Parameters:
    K - the type of keys maintained by this cache
    V - the type of mapped values
    All Implemented Interfaces:
    Cache<K,​V>, AutoCloseable

    public class DefaultCache<K,​V>
    extends ConcurrentCacheBase<K,​V>
    implements AutoCloseable
    Default implementation of the Cache interface.

    This implementation is thread-safe and supports various cache configurations including eviction strategies, expiration policies, and event listeners. It provides both synchronous and asynchronous operations for maximum flexibility.

    Performance Optimizations: This implementation uses striped locking to reduce contention, optimized expiration checks using nanoTime, and minimizes object allocation in hot paths.

    Since:
    1.0.0
    See Also:
    CacheConfig, CacheEventListener
    • Constructor Detail

      • DefaultCache

        public DefaultCache​(CacheConfig<K,​V> config)
        Creates a new DefaultCache with the specified configuration.
    • Method Detail

      • scheduleRefresh

        protected void scheduleRefresh()
        Schedule refresh operations for entries that support refresh.
        Overrides:
        scheduleRefresh in class ConcurrentCacheBase<K,​V>
      • close

        public void close()
        Closes this cache and releases any resources associated with it.
        Specified by:
        close in interface AutoCloseable