Class CacheManager

java.lang.Object
org.deltava.util.cache.CacheManager

public class CacheManager extends Object
A utility class to handle centralized cache registration and invalidation.
Since:
5.0
Version:
11.5
Author:
Luke
  • Method Details

    • init

      public static void init(String id)
      Initializes the cache Manager.
      Parameters:
      id - the application ID
    • getCacheInfo

      public static Collection<CacheInfo> getCacheInfo(boolean getRemoteSize)
      Returns information about all caches.
      Parameters:
      getRemoteSize - TRUE to fetch remote cache sizes, otherwise FALSE
      Returns:
      a Collection of CacheInfo objects
    • invalidate

      public static void invalidate(String id)
      Invalidates a cache.
      Parameters:
      id - the cache ID
    • invalidate

      public static void invalidate(String id, boolean sendEvent)
      Invalidates a cache.
      Parameters:
      id - the cache ID
      sendEvent - sends a system Event to other webapps if TRUE and remote
    • invalidate

      public static void invalidate(String id, Object key)
      Invalidates a cache entry.
      Parameters:
      id - the cache ID
      key - the cache key
    • register

      static <T extends Cacheable> Cache<T> register(Class<T> c, CacheConfig cfg)
      Registers a cache.
      Parameters:
      c - the cache content class
      cfg - the CacheConfig bean
      Returns:
      a Cache
    • get

      public static <T extends Cacheable> Cache<T> get(Class<T> c, String id)
      Retrieves an existing cache. This will return a NullCache if the cache ID has not been registered.
      Parameters:
      c - the cache content class
      id - the cache ID
      Returns:
      a Cache
    • getGeo

      public static <T extends Cacheable> GeoCache<T> getGeo(Class<T> c, String id)
      Retrieves an existing GeoCache. This will return a NullCache if the cache ID has not been registered.
      Parameters:
      c - the cache content class
      id - the cache ID
      Returns:
      a GeoCache
    • getCollection

      public static <U, T extends CacheableCollection<U>> Cache<T> getCollection(Class<U> c, String id)
      Retrieves an existing Collection cache. This will return a NullCache if the cache ID has not been registered.
      Parameters:
      c - the cache Collection content class
      id - the cache ID
      Returns:
      a Cache
    • getMap

      public static <K, V, T extends CacheableMap<K,V>> Cache<T> getMap(Class<K> k, Class<V> v, String id)
      Retrieves an existing Map cache. This will return a NullCache if the cache ID has not been registered.
      Parameters:
      k - the cache Map content key class
      v - the cache Map content value class
      id - the Cache ID
      Returns:
      a Cache