Class FileSystemStore

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

public class FileSystemStore extends AbstractStore
This object store keeps all objects in the file system. Each object is stored in a separate file.
  • Constructor Details

    • FileSystemStore

      public FileSystemStore()
      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
    • getDirectory

      public Path getDirectory()
      Get the directory where the cache entries are stored
      Returns:
      The directory where the cache entries are stored
    • pathToCacheKey

      public Key pathToCacheKey(Path path)
      Converts a path object to an entry key by removing the extension
      Parameters:
      path - the Path object of the cache entry file
      Returns:
      The key of the cache entry
    • cacheKeyToPath

      public Path cacheKeyToPath(Key key)
      Converts a key to a full path object in the pool
      Parameters:
      key - The key of the cache entry
      Returns:
      The Path object of the cache entry file
    • 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 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
    • 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
    • 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