Class ConcurrentSoftReferenceStore

java.lang.Object
ortus.boxlang.runtime.cache.store.AbstractStore
ortus.boxlang.runtime.cache.store.ConcurrentSoftReferenceStore
All Implemented Interfaces:
IObjectStore

public class ConcurrentSoftReferenceStore extends AbstractStore
This object store keeps all objects in heap using Concurrent classes. Naturally the store is ordered by created timestamp and can be used for concurrent access.
  • Constructor Details

    • ConcurrentSoftReferenceStore

      public ConcurrentSoftReferenceStore()
      Constructor
  • Method Details

    • init

      public IObjectStore init(ICacheProvider provider, IStruct config)
      Some storages require a method to initialize the storage or do object loading. This method is called when the cache provider is started.
      Parameters:
      provider - The cache provider associated with this store
      config - The configuration for the store
    • getPool

      Get the pool of objects ConcurrentStore uses a ConcurrentHashMap to store the objects
      Returns:
      The pool of objects
    • shutdown

      public void shutdown()
      Some storages require a shutdown method to close the storage or do object saving. This method is called when the cache provider is stopped.
    • flush

      public int flush()
      Flush the store to a permanent storage. Only applicable to stores that support it. Not supported by this pool.
      Returns:
      The number of objects flushed
    • evict

      public void evict()
      Runs the eviction algorithm to remove objects from the store based on the eviction policy and eviction count.
    • getSize

      public int getSize()
      Get the size of the store, not the size in bytes but the number of objects in the store
    • clearAll

      public void clearAll()
      Clear all the elements in the store
    • clearAll

      public boolean clearAll(ICacheKeyFilter filter)
      Clear all the elements in the store with a $ICacheKeyFilter. This can be a lambda or method reference since it's a functional interface.
      Parameters:
      filter - The filter that determines which keys to clear
      Returns:
      The number of objects cleared
    • clear

      public boolean clear(Key key)
      Clears an object from the storage
      Parameters:
      key - The object key to clear
      Returns:
      True if the object was cleared, false otherwise (if the object was not found in the store)
    • clear

      public IStruct clear(Key... keys)
      Clears multiple objects from the storage
      Parameters:
      keys - The keys to clear
      Returns:
      A struct of keys and their clear status: true if the object was cleared, false otherwise (if the object was not found in the store)
    • getKeys

      public Key[] getKeys()
      Get all the keys in the store
      Returns:
      An array of keys in the cache
    • getKeys

      public Key[] getKeys(ICacheKeyFilter filter)
      Get all the keys in the store using a filter
      Parameters:
      filter - The filter that determines which keys to return
      Returns:
      An array of keys in the cache
    • getKeysStream

      public Stream<Key> getKeysStream()
      Get all the keys in the store as a stream
      Returns:
      A stream of keys in the cache
    • getKeysStream

      public Stream<Key> getKeysStream(ICacheKeyFilter filter)
      Get all the keys in the store as a stream
      Parameters:
      filter - The filter that determines which keys to return
      Returns:
      A stream of keys in the cache
    • lookup

      public boolean lookup(Key key)
      Check if an object is in the store
      Parameters:
      key - The key to lookup in the store
      Returns:
      True if the object is in the store, false otherwise
    • lookup

      public IStruct lookup(Key... keys)
      Check if multiple objects are in the store
      Parameters:
      keys - A varargs of keys to lookup in the store
      Returns:
      A struct of keys and their lookup status
    • lookup

      public IStruct lookup(ICacheKeyFilter filter)
      Check if multiple objects are in the store using a filter
      Parameters:
      filter - The filter that determines which keys to return
      Returns:
      A struct of the keys found. True if the object is in the store, false otherwise
    • get

      public ICacheEntry get(Key key)
      Get an object from the store with metadata tracking: hits, lastAccess, etc
      Parameters:
      key - The key to retrieve
      Returns:
      The cache entry retrieved or null if not found
    • get

      public IStruct get(Key... keys)
      Get multiple objects from the store with metadata tracking
      Parameters:
      keys - The keys to retrieve
      Returns:
      A struct of keys and their cache entries
    • get

      public IStruct get(ICacheKeyFilter filter)
      Get multiple objects from the store with metadata tracking using a filter
      Parameters:
      filter - The filter that determines which keys to return
      Returns:
      A struct of keys and their cache entries
    • getQuiet

      public IStruct getQuiet(Key... keys)
      Get multiple objects from the store with no metadata tracking
      Parameters:
      keys - The keys to retrieve
      Returns:
      A struct of keys and their cache entries
    • getQuiet

      public IStruct getQuiet(ICacheKeyFilter filter)
      Get multiple objects from the store with no metadata tracking using a filter
      Parameters:
      filter - The filter that determines which keys to return
      Returns:
      A struct of keys and their cache entries
    • getQuiet

      public ICacheEntry getQuiet(Key key)
      Get an object from cache with no metadata tracking
      Parameters:
      key - The key to retrieve
      Returns:
      The cache entry retrieved or null if not found
    • set

      public void set(Key key, ICacheEntry entry)
      Sets an object in the storage
      Parameters:
      key - The key to store the object under
      entry - The cache entry to store
    • set

      public void set(IStruct entries)
      Set's multiple objects in the storage
      Parameters:
      entries - The keys and cache entries to store
    • evictSoftReferences

      public void evictSoftReferences()
      Evict soft references from the store that have been collected