Class LuteceCacheManager

java.lang.Object
fr.paris.lutece.portal.service.cache.LuteceCacheManager
All Implemented Interfaces:
ILuteceCacheManager

@ApplicationScoped public class LuteceCacheManager extends Object implements ILuteceCacheManager
Manages the creation and retrieval of cache instances (Lutece107Cache) in the Lutece application.

This class uses CDI to manage cache instances, providing methods to create and retrieve caches based on their name, key type, value type, and configuration settings.

  • Constructor Details

    • LuteceCacheManager

      public LuteceCacheManager()
  • Method Details

    • createCache

      public <K, V, C extends javax.cache.configuration.Configuration<K, V>> Lutece107Cache<K,V> createCache(String strCacheName, C configuration, boolean enable) throws IllegalArgumentException
      Creates a named Cache at runtime.

      If a Cache with the specified name is known to the CacheManager, a CacheException is thrown.

      If a Cache with the specified name is unknown the CacheManager, one is created according to the provided Configuration after which it becomes managed by the CacheManager.

      Prior to a Cache being created, the provided Configurations is validated within the context of the CacheManager properties and implementation.

      Implementers should be aware that the Configuration may be used to configure other Caches.

      There's no requirement on the part of a developer to call this method for each Cache an application may use. Implementations may support the use of declarative mechanisms to pre-configure Caches, thus removing the requirement to configure them in an application. In such circumstances a developer may simply call either the ILuteceCacheManager.getCache(String) or ILuteceCacheManager.getCache(String, Class, Class) methods to acquire a previously established or pre-configured Cache.

      Specified by:
      createCache in interface ILuteceCacheManager
      Type Parameters:
      K - the type of key
      V - the type of value
      C - the type of the Configuration
      Parameters:
      strCacheName - the name of the Cache. Names should not use forward slashes(/) or colons(:), or start with java. or javax. These prefixes are reserved.
      configuration - a Configuration for the Cache
      enable - If enable is set to true, the cache will be initialized upon its creation.
      Throws:
      IllegalArgumentException - if the configuration is invalid
    • createCache

      public <K, V> Lutece107Cache<K,V> createCache(String strCacheName) throws IllegalArgumentException
      Creates a named Cache at runtime.

      If a Cache with the specified name is known to the CacheManager, a CacheException is thrown.

      If a Cache with the specified name is unknown the CacheManager, one is created according to the provided Configuration after which it becomes managed by the CacheManager.

      Prior to a Cache being created, the provided Configurations is validated within the context of the CacheManager properties and implementation.

      Implementers should be aware that the Configuration may be used to configure other Caches.

      There's no requirement on the part of a developer to call this method for each Cache an application may use. Implementations may support the use of declarative mechanisms to pre-configure Caches, thus removing the requirement to configure them in an application. In such circumstances a developer may simply call either the ILuteceCacheManager.getCache(String) or ILuteceCacheManager.getCache(String, Class, Class) methods to acquire a previously established or pre-configured Cache.

      Specified by:
      createCache in interface ILuteceCacheManager
      Type Parameters:
      K - the type of key
      V - the type of value
      Parameters:
      strCacheName - the name of the Cache. Names should not use forward slashes(/) or colons(:), or start with java. or javax. These prefixes are reserved.
      Throws:
      IllegalArgumentException - if the configuration is invalid
    • createCache

      public <K, V, C extends javax.cache.configuration.Configuration<K, V>> Lutece107Cache<K,V> createCache(String strCacheName, Class<K> k, Class<V> v) throws IllegalArgumentException
      Creates a named Cache at runtime.

      If a Cache with the specified name is known to the CacheManager, a CacheException is thrown.

      If a Cache with the specified name is unknown the CacheManager, one is created according to the provided Configuration after which it becomes managed by the CacheManager.

      Prior to a Cache being created, the provided Configurations is validated within the context of the CacheManager properties and implementation.

      Implementers should be aware that the Configuration may be used to configure other Caches.

      There's no requirement on the part of a developer to call this method for each Cache an application may use. Implementations may support the use of declarative mechanisms to pre-configure Caches, thus removing the requirement to configure them in an application. In such circumstances a developer may simply call either the ILuteceCacheManager.getCache(String) or ILuteceCacheManager.getCache(String, Class, Class) methods to acquire a previously established or pre-configured Cache.

      Specified by:
      createCache in interface ILuteceCacheManager
      Type Parameters:
      K - the type of key
      V - the type of value
      C - the type of the Configuration
      Parameters:
      strCacheName - the name of the Cache. Names should not use forward slashes(/) or colons(:), or start with java. or javax. These prefixes are reserved.
      Throws:
      IllegalArgumentException - if the configuration is invalid
    • createCache

      public <K, V, C extends javax.cache.configuration.Configuration<K, V>> Lutece107Cache<K,V> createCache(String strCacheName, Class<K> k, Class<V> v, boolean enable) throws IllegalArgumentException
      Creates a named Cache at runtime.

      If a Cache with the specified name is known to the CacheManager, a CacheException is thrown.

      If a Cache with the specified name is unknown the CacheManager, one is created according to the provided Configuration after which it becomes managed by the CacheManager.

      Prior to a Cache being created, the provided Configurations is validated within the context of the CacheManager properties and implementation.

      Implementers should be aware that the Configuration may be used to configure other Caches.

      There's no requirement on the part of a developer to call this method for each Cache an application may use. Implementations may support the use of declarative mechanisms to pre-configure Caches, thus removing the requirement to configure them in an application. In such circumstances a developer may simply call either the ILuteceCacheManager.getCache(String) or ILuteceCacheManager.getCache(String, Class, Class) methods to acquire a previously established or pre-configured Cache.

      Specified by:
      createCache in interface ILuteceCacheManager
      Type Parameters:
      K - the type of key
      V - the type of value
      C - the type of the Configuration
      enable - If enable is set to true, the cache will be initialized upon its creation.
      Throws:
      IllegalArgumentException - if the configuration is invalid
    • createCache

      public <K, V, C extends javax.cache.configuration.Configuration<K, V>> Lutece107Cache<K,V> createCache(String strCacheName, Class<K> k, Class<V> v, boolean enable, boolean automaticResetDisabled) throws IllegalArgumentException
      Description copied from interface: ILuteceCacheManager
      Creates a named Cache at runtime.

      If a Cache with the specified name is known to the CacheManager, a CacheException is thrown.

      If a Cache with the specified name is unknown the CacheManager, one is created according to the provided Configuration after which it becomes managed by the CacheManager.

      Prior to a Cache being created, the provided Configurations is validated within the context of the CacheManager properties and implementation.

      Implementers should be aware that the Configuration may be used to configure other Caches.

      There's no requirement on the part of a developer to call this method for each Cache an application may use. Implementations may support the use of declarative mechanisms to pre-configure Caches, thus removing the requirement to configure them in an application. In such circumstances a developer may simply call either the ILuteceCacheManager.getCache(String) or ILuteceCacheManager.getCache(String, Class, Class) methods to acquire a previously established or pre-configured Cache.

      Specified by:
      createCache in interface ILuteceCacheManager
      Type Parameters:
      K - the type of key
      V - the type of value
      C - the type of the Configuration
      enable - If enable is set to true, the cache will be initialized upon its creation.
      automaticResetDisabled - If set to true, the cache will not be reset by global cache resets, like resetAll
      Throws:
      IllegalArgumentException - if the configuration is invalid
    • getCache

      public <K, V> Lutece107Cache<K,V> getCache(String cacheName, Class<K> k, Class<V> v)
      Looks up a managed Cache given its name.

      Use this method to check runtime key and value types.

      Use ILuteceCacheManager.getCache(String) where this check is not required.

      Implementations must ensure that the key and value types are the same as those configured for the Cache prior to returning from this method.

      Implementations may further perform type checking on mutative cache operations and throw a ClassCastException if these checks fail.

      Implementations that support declarative mechanisms for pre-configuring Caches may return a pre-configured Cache instead of null.

      Specified by:
      getCache in interface ILuteceCacheManager
      Type Parameters:
      K - the type of key
      V - the type of value
      Parameters:
      cacheName - the name of the managed Cache to acquire
      k - the expected Class of the key
      v - the expected Class of the value
      Returns:
      the Cache or null if it does exist or can't be pre-configured
    • getCache

      public <K, V> Lutece107Cache<K,V> getCache(String cacheName)
      Looks up a managed Cache given its name.
      Specified by:
      getCache in interface ILuteceCacheManager
      Type Parameters:
      K - the type of key
      V - the type of value
      Parameters:
      cacheName - the name of the managed Cache to acquire
      Returns:
      the Cache or null if it does exist or can't be pre-configured