Class CacheService
- java.lang.Object
-
- de.julielab.java.utilities.cache.CacheService
-
public class CacheService extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCacheService.CacheMapDataTypestatic classCacheService.CachePersistenceTypestatic classCacheService.CacheType
-
Field Summary
Fields Modifier and Type Field Description static StringCACHING_ENABLED_PROPJava system property name to enable or disable caching.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcommitAllCaches()<K,V>
CacheAccess<K,V>getCacheAccess(String cacheId, String cacheRegion, String keySerializerName, String valueSerializerName)This is the method to acquire an actual cache object.<K,V>
CacheAccess<K,V>getCacheAccess(String cacheId, String cacheRegion, String keySerializerName, String valueSerializerName, long memCacheSize)This is the method to acquire an actual cache object.<K,V>
CacheAccess<K,V>getCacheAccess(String cacheId, String cacheRegion, String keySerializerName, String valueSerializerName, CacheMapSettings mapSettings)static CacheServicegetInstance()static voidinitialize(CacheConfiguration configuration)
-
-
-
Field Detail
-
CACHING_ENABLED_PROP
public static final String CACHING_ENABLED_PROP
Java system property name to enable or disable caching. No value is interpreted as 'true'.
This property can be used to disable caching. When set to 'false', all methods returning an instance of
CacheAccesswill return the implementationNoOpCacheAccess. This implementation caches nothing and always returns null forCacheAccess.get(Object).If caching is disabled, the call to
initialize(CacheConfiguration)is no longer necessary.- See Also:
- Constant Field Values
-
-
Method Detail
-
getInstance
public static CacheService getInstance()
-
initialize
public static void initialize(CacheConfiguration configuration)
-
getCacheAccess
public <K,V> CacheAccess<K,V> getCacheAccess(String cacheId, String cacheRegion, String keySerializerName, String valueSerializerName)
This is the method to acquire an actual cache object.
Calling this method results in the creation of or the opening of a concrete cache file. The file will be created in the directory given by
CacheConfiguration.getLocalCacheDir()or the respective parameter when starting the cache server in case of a remote cache.- Type Parameters:
K- The cache key type.V- The cache value type.- Parameters:
cacheId- An arbitrary name that names the resulting cache file.cacheRegion- An arbitrary name of a region in within the given cacheId.keySerializerName- One ofCacheAccess.STRING,CacheAccess.JAVA,CacheAccess.BYTEARRAYorCacheAccess.DOUBLEARRAY.valueSerializerName- One ofCacheAccess.STRING,CacheAccess.JAVA,CacheAccess.BYTEARRAYorCacheAccess.DOUBLEARRAY.- Returns:
- An object granting access to the requested cache.
-
getCacheAccess
public <K,V> CacheAccess<K,V> getCacheAccess(String cacheId, String cacheRegion, String keySerializerName, String valueSerializerName, long memCacheSize)
This is the method to acquire an actual cache object.
Calling this method results in the creation of or the opening of a concrete cache file. The file will be created in the directory given by
CacheConfiguration.getLocalCacheDir()or the respective parameter when starting the cache server in case of a remote cache.- Type Parameters:
K- The cache key type.V- The cache value type.- Parameters:
cacheId- An arbitrary name that names the resulting cache file.cacheRegion- An arbitrary name of a region in within the given cacheId.keySerializerName- One ofCacheAccess.STRING,CacheAccess.JAVA,CacheAccess.BYTEARRAYorCacheAccess.DOUBLEARRAY.valueSerializerName- One ofCacheAccess.STRING,CacheAccess.JAVA,CacheAccess.BYTEARRAYorCacheAccess.DOUBLEARRAY.memCacheSize- The size of the in-memory cache buffer.- Returns:
- An object granting access to the requested cache.
-
getCacheAccess
public <K,V> CacheAccess<K,V> getCacheAccess(String cacheId, String cacheRegion, String keySerializerName, String valueSerializerName, CacheMapSettings mapSettings)
-
commitAllCaches
public void commitAllCaches()
-
-