Class AbstractCacheProvider

java.lang.Object
ortus.boxlang.runtime.cache.providers.AbstractCacheProvider
All Implemented Interfaces:
ICacheProvider
Direct Known Subclasses:
BoxCacheProvider

public abstract class AbstractCacheProvider extends Object implements ICacheProvider
Abstract Cache Provider for BoxLang This is an optional base class for all cache providers.
  • Field Details

    • TYPES

      public static final Class<ObjectStoreType> TYPES
      -------------------------------------------------------------------------- Public Properties --------------------------------------------------------------------------
    • name

      protected Key name
      The name of the cache provider
    • enabled

      protected AtomicBoolean enabled
      Atomic Boolean if the cache provider is enabled
    • reportingEnabled

      protected boolean reportingEnabled
      Reporting enabled bit
    • stats

      protected ICacheStats stats
      The ICacheStats object for this cache provider
    • config

      protected CacheConfig config
      The cache configuration
    • cacheService

      protected CacheService cacheService
      Cache Service
    • interceptorPool

      protected InterceptorPool interceptorPool
      Interceptor Local Pool
  • Constructor Details

    • AbstractCacheProvider

      public AbstractCacheProvider()
  • Method Details

    • getCacheService

      public CacheService getCacheService()
      Get the cache service that is using this provider
      Specified by:
      getCacheService in interface ICacheProvider
      Returns:
      The cache service
    • getStats

      public ICacheStats getStats()
      Get the cache stats
      Specified by:
      getStats in interface ICacheProvider
    • getInterceptorPool

      public InterceptorPool getInterceptorPool()
      Get the interceptor pool for this cache
      Specified by:
      getInterceptorPool in interface ICacheProvider
    • clearStats

      public ICacheProvider clearStats()
      Clear The stats
      Specified by:
      clearStats in interface ICacheProvider
      Returns:
      The cache provider
    • getName

      public Key getName()
      Get the name of the cache provider
      Specified by:
      getName in interface ICacheProvider
    • setName

      public ICacheProvider setName(String name)
      Set the name of the cache provider
      Parameters:
      name - The name of the cache provider
      Returns:
      The cache provider
    • setName

      public ICacheProvider setName(Key name)
      Set the name of the cache provider
      Specified by:
      setName in interface ICacheProvider
      Parameters:
      name - The name of the cache provider
      Returns:
      The cache provider
    • getType

      public String getType()
      Get the provider type
      Specified by:
      getType in interface ICacheProvider
      Returns:
      The provider type
    • getConfig

      public CacheConfig getConfig()
      Get the cache configuration
      Specified by:
      getConfig in interface ICacheProvider
      Returns:
      The cache configuration
    • isEnabled

      public boolean isEnabled()
      Is it enabled
      Specified by:
      isEnabled in interface ICacheProvider
    • isReportingEnabled

      public boolean isReportingEnabled()
      Is reporting enabled
      Specified by:
      isReportingEnabled in interface ICacheProvider
    • getCachedObjectMetadata

      public IStruct getCachedObjectMetadata(String... key)
      Get a cache objects metadata about its performance. This value is a structure of name-value pairs of metadata.
      Specified by:
      getCachedObjectMetadata in interface ICacheProvider
      Parameters:
      key - A varargs of keys of the object
      Returns:
      The metadata structure of structures
    • configure

      public ICacheProvider configure(CacheService cacheService, CacheConfig config)
      Configure the cache provider for operation
      Specified by:
      configure in interface ICacheProvider
      Parameters:
      cacheService - The cache service that is configuring the cache provider
      config - The configuration object
      Returns:
      The cache provider
    • getAsync

      public CompletableFuture<Attempt<Object>> getAsync(String key)
      Get an object from the store with metadata tracking using a CompletableFuture
      Specified by:
      getAsync in interface ICacheProvider
      Parameters:
      key - The key to retrieve
      Returns:
      CompletableFuture of the value retrieved or null
    • getTaskScheduler

      protected ExecutorRecord getTaskScheduler()
      Get a referece to the CacheService Task Scheduler
      Returns:
      The task scheduler
    • memoryThresholdCheck

      protected boolean memoryThresholdCheck()
      JVM Threshold checks
    • announce

      protected void announce(Key event, IStruct data)
      Announce an event in the Runtime and the local pool with the provided IStruct of data.
      Parameters:
      event - The event to announce
      data - The data to announce
    • announce

      public void announce(BoxEvent state, IStruct data)
      Announce an event with the provided IStruct of data.
      Parameters:
      state - The state key to announce
      data - The data to announce
    • buildObjectStore

      protected static IObjectStore buildObjectStore(CacheConfig config)
      Build out the object store according to the configuration
      Parameters:
      config - The configuration
      Returns:
      The object store created and configured
    • buildObjectStoreByClass

      protected static IObjectStore buildObjectStoreByClass(String storeClasspath)
      Build the object store by class path
      Parameters:
      storeClasspath - The class path of the object store
      Returns:
      The object store
      Throws:
      BoxRuntimeException - If the object store cannot be loaded
      BoxRuntimeException - If the object store does not implement IObjectStore
      BoxRuntimeException - If the object store cannot be instantiated