- java.lang.Object
-
- org.omnifaces.util.cache.CacheInstancePerScopeProvider
-
- All Implemented Interfaces:
CacheProvider
- Direct Known Subclasses:
DefaultCacheProvider
public abstract class CacheInstancePerScopeProvider extends Object implements CacheProvider
Base class for Cache providers where for each scope a new instance of the cache is created if for that scope no instance is present yet.This kind of cache provider is suitable for simple in-memory cache implementations, where the cache is very cheap to create. This is in contrast to caches where there is typically one expensive to create instance active per JVM, and where scoped caches are better expressed as nodes in a tree structure.
- Since:
- 1.1
- Author:
- Arjan Tijms
-
-
Field Summary
Fields Modifier and Type Field Description static String
APP_MAX_CAP_PARAM_NAME
static String
APP_TTL_PARAM_NAME
static String
DEFAULT_CACHE_PARAM_NAME
static String
SESSION_MAX_CAP_PARAM_NAME
static String
SESSION_TTL_PARAM_NAME
-
Constructor Summary
Constructors Constructor Description CacheInstancePerScopeProvider()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract Cache
createCache(Integer timeToLive, Integer maxCapacity)
Cache
getCache(FacesContext context, String scope)
Gets an instance of a Cache using the configured cache provider.Map<String,String>
getParameters()
void
setParameters(Map<String,String> parameters)
Passes parameters to the cache provider implementation.
-
-
-
Field Detail
-
DEFAULT_CACHE_PARAM_NAME
public static final String DEFAULT_CACHE_PARAM_NAME
- See Also:
- Constant Field Values
-
APP_TTL_PARAM_NAME
public static final String APP_TTL_PARAM_NAME
- See Also:
- Constant Field Values
-
SESSION_TTL_PARAM_NAME
public static final String SESSION_TTL_PARAM_NAME
- See Also:
- Constant Field Values
-
APP_MAX_CAP_PARAM_NAME
public static final String APP_MAX_CAP_PARAM_NAME
- See Also:
- Constant Field Values
-
SESSION_MAX_CAP_PARAM_NAME
public static final String SESSION_MAX_CAP_PARAM_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
getCache
public Cache getCache(FacesContext context, String scope)
Description copied from interface:CacheProvider
Gets an instance of a Cache using the configured cache provider.- Specified by:
getCache
in interfaceCacheProvider
- Parameters:
context
- faces context used for resolving the given scope.scope
- scope for which the cache should be obtained. Supported scopes are dependent on the specific caching provider, but generally at least "session" and "application" should be supported.- Returns:
- Cache instance encapsulating the cache represented by this CacheProvider
-
setParameters
public void setParameters(Map<String,String> parameters)
Description copied from interface:CacheProvider
Passes parameters to the cache provider implementation. This is mainly intended for configuration of things like LRU and global TTL. Settings are mainly implementation specific.- Specified by:
setParameters
in interfaceCacheProvider
- Parameters:
parameters
- map of parameters used to configure the cache.
-
-