Interface IObjectStore

All Known Implementing Classes:
AbstractStore, BlackHoleStore, ConcurrentSoftReferenceStore, ConcurrentStore, FileSystemStore

public interface IObjectStore
The main interface for object storages for a BoxLangCache. This store can be used to store objects in memory or in a persistent storage or whatever you want. A cache provider coordinates user interactions an acts more like a cache service to the underlying cache store. Each object store must adhere to this interface and will receive Key objects as keys so the object store can decide how to store the objects if in case-sensitive or case-insensitive manner. Each object store will also use the ICacheEntry to store the data so it's consistent across all cache providers and stores. You can implement your own store to store objects in a different way or create your own cache provider to talk to different Caches as well.
  • Method Details

    • getName

      String getName()
      Get the name of the store
      Returns:
      The name of the store
    • getConfig

      IStruct getConfig()
      Get the configuration for the store
    • getProvider

      ICacheProvider getProvider()
      Get the associated cache provider
    • init

      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
    • shutdown

      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

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

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

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

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

      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

      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

      IStruct clear(Key... keys)
      Clears multiple objects from the storage
      Parameters:
      keys - The key(s) to clear
      Returns:
      A struct of keys and their clear status
    • getKeys

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

      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

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

      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

      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

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

      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 keys and their lookup status
    • get

      ICacheEntry get(Key key)
      Get an object from the store with metadata tracking
      Parameters:
      key - The key to retrieve
      Returns:
      The cache entry retrieved or null
    • get

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

      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

      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
    • getQuiet

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

      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
    • set

      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

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