Class LuteceCacheManager
- All Implemented Interfaces:
ILuteceCacheManager
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<K,V> Lutece107Cache<K, V> createCache(String strCacheName) Creates a namedCacheat runtime.<K,V, C extends javax.cache.configuration.Configuration<K, V>>
Lutece107Cache<K,V> createCache(String strCacheName, C configuration, boolean enable) Creates a namedCacheat runtime.<K,V, C extends javax.cache.configuration.Configuration<K, V>>
Lutece107Cache<K,V> createCache(String strCacheName, Class<K> k, Class<V> v) Creates a namedCacheat runtime.<K,V, C extends javax.cache.configuration.Configuration<K, V>>
Lutece107Cache<K,V> createCache(String strCacheName, Class<K> k, Class<V> v, boolean enable) Creates a namedCacheat runtime.<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) Creates a namedCacheat runtime.<K,V> Lutece107Cache<K, V> Looks up a managedCachegiven its name.<K,V> Lutece107Cache<K, V> Looks up a managedCachegiven its name.
-
Constructor Details
-
LuteceCacheManager
public LuteceCacheManager()
-
-
Method Details
-
createCache
public <K,V, Lutece107Cache<K,C extends javax.cache.configuration.Configuration<K, V>> V> createCache(String strCacheName, C configuration, boolean enable) throws IllegalArgumentException Creates a namedCacheat runtime.If a
Cachewith the specified name is known to theCacheManager, a CacheException is thrown.If a
Cachewith the specified name is unknown theCacheManager, one is created according to the providedConfigurationafter which it becomes managed by theCacheManager.Prior to a
Cachebeing created, the providedConfigurations is validated within the context of theCacheManagerproperties and implementation.Implementers should be aware that the
Configurationmay be used to configure otherCaches.There's no requirement on the part of a developer to call this method for each
Cachean application may use. Implementations may support the use of declarative mechanisms to pre-configureCaches, thus removing the requirement to configure them in an application. In such circumstances a developer may simply call either theILuteceCacheManager.getCache(String)orILuteceCacheManager.getCache(String, Class, Class)methods to acquire a previously established or pre-configuredCache.- Specified by:
createCachein interfaceILuteceCacheManager- Type Parameters:
K- the type of keyV- the type of valueC- the type of the Configuration- Parameters:
strCacheName- the name of theCache. Names should not use forward slashes(/) or colons(:), or start with java. or javax. These prefixes are reserved.configuration- aConfigurationfor theCacheenable- If enable is set to true, the cache will be initialized upon its creation.- Throws:
IllegalArgumentException- if the configuration is invalid
-
createCache
Creates a namedCacheat runtime.If a
Cachewith the specified name is known to theCacheManager, a CacheException is thrown.If a
Cachewith the specified name is unknown theCacheManager, one is created according to the providedConfigurationafter which it becomes managed by theCacheManager.Prior to a
Cachebeing created, the providedConfigurations is validated within the context of theCacheManagerproperties and implementation.Implementers should be aware that the
Configurationmay be used to configure otherCaches.There's no requirement on the part of a developer to call this method for each
Cachean application may use. Implementations may support the use of declarative mechanisms to pre-configureCaches, thus removing the requirement to configure them in an application. In such circumstances a developer may simply call either theILuteceCacheManager.getCache(String)orILuteceCacheManager.getCache(String, Class, Class)methods to acquire a previously established or pre-configuredCache.- Specified by:
createCachein interfaceILuteceCacheManager- Type Parameters:
K- the type of keyV- the type of value- Parameters:
strCacheName- the name of theCache. 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, Lutece107Cache<K,C extends javax.cache.configuration.Configuration<K, V>> V> createCache(String strCacheName, Class<K> k, Class<V> v) throws IllegalArgumentException Creates a namedCacheat runtime.If a
Cachewith the specified name is known to theCacheManager, a CacheException is thrown.If a
Cachewith the specified name is unknown theCacheManager, one is created according to the providedConfigurationafter which it becomes managed by theCacheManager.Prior to a
Cachebeing created, the providedConfigurations is validated within the context of theCacheManagerproperties and implementation.Implementers should be aware that the
Configurationmay be used to configure otherCaches.There's no requirement on the part of a developer to call this method for each
Cachean application may use. Implementations may support the use of declarative mechanisms to pre-configureCaches, thus removing the requirement to configure them in an application. In such circumstances a developer may simply call either theILuteceCacheManager.getCache(String)orILuteceCacheManager.getCache(String, Class, Class)methods to acquire a previously established or pre-configuredCache.- Specified by:
createCachein interfaceILuteceCacheManager- Type Parameters:
K- the type of keyV- the type of valueC- the type of the Configuration- Parameters:
strCacheName- the name of theCache. 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, Lutece107Cache<K,C extends javax.cache.configuration.Configuration<K, V>> V> createCache(String strCacheName, Class<K> k, Class<V> v, boolean enable) throws IllegalArgumentException Creates a namedCacheat runtime.If a
Cachewith the specified name is known to theCacheManager, a CacheException is thrown.If a
Cachewith the specified name is unknown theCacheManager, one is created according to the providedConfigurationafter which it becomes managed by theCacheManager.Prior to a
Cachebeing created, the providedConfigurations is validated within the context of theCacheManagerproperties and implementation.Implementers should be aware that the
Configurationmay be used to configure otherCaches.There's no requirement on the part of a developer to call this method for each
Cachean application may use. Implementations may support the use of declarative mechanisms to pre-configureCaches, thus removing the requirement to configure them in an application. In such circumstances a developer may simply call either theILuteceCacheManager.getCache(String)orILuteceCacheManager.getCache(String, Class, Class)methods to acquire a previously established or pre-configuredCache.- Specified by:
createCachein interfaceILuteceCacheManager- Type Parameters:
K- the type of keyV- the type of valueC- the type of the Configurationenable- 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,C extends javax.cache.configuration.Configuration<K, V>> V> createCache(String strCacheName, Class<K> k, Class<V> v, boolean enable, boolean automaticResetDisabled) throws IllegalArgumentException Description copied from interface:ILuteceCacheManagerCreates a namedCacheat runtime.If a
Cachewith the specified name is known to theCacheManager, a CacheException is thrown.If a
Cachewith the specified name is unknown theCacheManager, one is created according to the providedConfigurationafter which it becomes managed by theCacheManager.Prior to a
Cachebeing created, the providedConfigurations is validated within the context of theCacheManagerproperties and implementation.Implementers should be aware that the
Configurationmay be used to configure otherCaches.There's no requirement on the part of a developer to call this method for each
Cachean application may use. Implementations may support the use of declarative mechanisms to pre-configureCaches, thus removing the requirement to configure them in an application. In such circumstances a developer may simply call either theILuteceCacheManager.getCache(String)orILuteceCacheManager.getCache(String, Class, Class)methods to acquire a previously established or pre-configuredCache.- Specified by:
createCachein interfaceILuteceCacheManager- Type Parameters:
K- the type of keyV- the type of valueC- the type of the Configurationenable- 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
Looks up a managedCachegiven 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
Cacheprior to returning from this method.Implementations may further perform type checking on mutative cache operations and throw a
ClassCastExceptionif these checks fail.Implementations that support declarative mechanisms for pre-configuring
Caches may return a pre-configuredCacheinstead ofnull.- Specified by:
getCachein interfaceILuteceCacheManager- Type Parameters:
K- the type of keyV- the type of value- Parameters:
cacheName- the name of the managedCacheto acquirek- the expectedClassof the keyv- the expectedClassof the value- Returns:
- the Cache or null if it does exist or can't be pre-configured
-
getCache
Looks up a managedCachegiven its name.- Specified by:
getCachein interfaceILuteceCacheManager- Type Parameters:
K- the type of keyV- the type of value- Parameters:
cacheName- the name of the managedCacheto acquire- Returns:
- the Cache or null if it does exist or can't be pre-configured
-