Class NearCache<K,V>

java.lang.Object
com.loomcache.client.cache.NearCache<K,V>
All Implemented Interfaces:
AutoCloseable

public class NearCache<K,V> extends Object implements AutoCloseable
A standalone, in-process near-cache with configurable eviction, TTL, max-idle tracking, and periodic cleanup.

This class is independent of LoomClient's built-in near-cache; use it directly when you want near-cache semantics in front of any arbitrary data source (not just a LoomCache map). Configure via the nested NearCache.NearCacheConfig record. Close the instance when done to shut down the background cleanup thread.

  • Constructor Details

  • Method Details

    • get

      public @Nullable V get(K key)
    • put

      public void put(K key, V value)
    • remove

      public void remove(K key)
    • invalidate

      public void invalidate(K key)
    • invalidateAll

      public void invalidateAll()
    • size

      public int size()
    • getStats

      public NearCache.NearCacheStats getStats()
    • getDetailedStats

      public NearCache.NearCacheStats getDetailedStats()
    • clearStats

      public void clearStats()
    • preload

      public void preload(Map<K,V> entries)
    • getEvictionPolicy

      public String getEvictionPolicy()
    • setEvictionPolicy

      public void setEvictionPolicy(NearCache.EvictionPolicy policy)
    • getEntryMetadata

      public @Nullable NearCache.CacheEntryMetadata getEntryMetadata(K key)
    • getCacheEfficiency

      public NearCache.CacheEfficiency getCacheEfficiency()
    • shutdown

      public void shutdown()
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable