Class AbstractCacheManager

java.lang.Object
alpine.server.cache.AbstractCacheManager
Direct Known Subclasses:
CacheManager

public abstract class AbstractCacheManager extends Object
AbstractCacheManager provides a per-class object cache.
Since:
1.5.0
  • Constructor Details

    • AbstractCacheManager

      protected AbstractCacheManager(long expiresAfter, TimeUnit timeUnit, long maxSize)
      Constructs a new AbstractCacheManager object.
      Parameters:
      expiresAfter - the number of time units to expire after
      timeUnit - the unit of measurement
      maxSize - the maximum size of the cache (per object type)
  • Method Details

    • get

      public <T> T get(Class clazz, String key)
      Retrieves an object (of the specified class) from cache.
      Type Parameters:
      T - the object type
      Parameters:
      clazz - the class of the object to retrieve from cache
      key - the unique identifier of the object to retrieve from cache
      Returns:
      the cached object (if found) or null if not found
      Since:
      1.5.0
    • get

      public <T> T get(Class clazz, String key, Function mappingFunction)
      Retrieves an object (of the specified class) from cache.
      Type Parameters:
      T - the object type
      Parameters:
      clazz - the class of the object to retrieve from cache
      key - the unique identifier of the object to retrieve from cache
      mappingFunction - the function to call if the object is not present in cache
      Returns:
      the cached object (if found) or null if not found and a mappingFunction is not specified
      Since:
      1.5.0
    • put

      public void put(String key, Object object)
      Adds an object to cache.
      Parameters:
      key - the unique identifier of the object to put into cache
      object - the object to put into cache.
      Since:
      1.5.0
    • remove

      public void remove(Class clazz, String key)
      Remove an object from cache.
      Parameters:
      clazz - the class of the object to remove from cache
      key - the unique identifier of the object to remove from cache
    • maintenance

      public void maintenance(Class clazz)
      Performs maintenance on the cache. Maintenance is automatically carried out and use of this method is normally not required. However, if maintenance must be performed immediately, use of this method may be called.
      Parameters:
      clazz - the class of the object to perform maintenance on
      Since:
      1.5.0