Package de.hybris.platform.cache2
Class AbstractObjectCacheManager<T>
- java.lang.Object
-
- de.hybris.platform.cache2.AbstractObjectCacheManager<T>
-
- All Implemented Interfaces:
ObjectCacheManager<T>
- Direct Known Subclasses:
Cache2Test.TestObjectCacheManager
,ObjectCacheManagerImpl
public abstract class AbstractObjectCacheManager<T> extends java.lang.Object implements ObjectCacheManager<T>
-
-
Constructor Summary
Constructors Constructor Description AbstractObjectCacheManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
fetch(ObjectKey<T> objectKey)
Looks for the object under the givenObjectKey
.ObjectCache<T>
getCache()
Returns the underlaying cache.protected java.lang.String
getDebugKey(ObjectKey<T> objectKey)
protected T
handleCreation(ObjectKey<T> objectKey)
Default implementation of how objects should be created.protected void
handleExpiration(ObjectKey<T> objectKey)
Default implementation simply removes the expired object.protected void
handleInvalidation(ObjectKey<T> objectKey)
Default implementation simply removed the invalidated object.protected T
handleRequest(ObjectKey<T> objectKey)
Default implementation simply requests the cache with the given key.void
invalidate(ObjectKey<T> objectKey)
Invalidates the object under the given (@link ObjectKey}void
setCache(ObjectCache<T> objectCache)
Set the underlaying cache implementationvoid
setExpirationCheck(boolean expirationCheck)
void
setObjectAutoCreation(boolean autocreate)
-
-
-
Method Detail
-
setObjectAutoCreation
public void setObjectAutoCreation(boolean autocreate)
-
setExpirationCheck
public void setExpirationCheck(boolean expirationCheck)
-
getCache
public ObjectCache<T> getCache()
Description copied from interface:ObjectCacheManager
Returns the underlaying cache. The cache does not have any automated management and provides only low-level access.- Specified by:
getCache
in interfaceObjectCacheManager<T>
- Returns:
- ObjectCache the cache implementation
-
setCache
public void setCache(ObjectCache<T> objectCache)
Description copied from interface:ObjectCacheManager
Set the underlaying cache implementation- Specified by:
setCache
in interfaceObjectCacheManager<T>
- Parameters:
objectCache
- the cache implementation
-
fetch
public T fetch(ObjectKey<T> objectKey)
Description copied from interface:ObjectCacheManager
Looks for the object under the givenObjectKey
. There are three possibilities:
When the object is found, it will be returned.
When no object is found, theObjectCreator
creates a new one. The newly created object will be put on the cache and returned.
When the signature of the objectKey is outdated, the appropriate cached object (when available) will be removed. The keys signature will be renewed, theObjectCreator
creates a new object which is put on the cache and returned.- Specified by:
fetch
in interfaceObjectCacheManager<T>
- Parameters:
objectKey
- ObjectKey- Returns:
- cached object.
-
invalidate
public void invalidate(ObjectKey<T> objectKey)
Description copied from interface:ObjectCacheManager
Invalidates the object under the given (@link ObjectKey}- Specified by:
invalidate
in interfaceObjectCacheManager<T>
- Parameters:
objectKey
- the object key
-
handleExpiration
protected void handleExpiration(ObjectKey<T> objectKey)
Default implementation simply removes the expired object.- Parameters:
objectKey
-
-
handleInvalidation
protected void handleInvalidation(ObjectKey<T> objectKey)
Default implementation simply removed the invalidated object.- Parameters:
objectKey
-
-
handleRequest
protected T handleRequest(ObjectKey<T> objectKey)
Default implementation simply requests the cache with the given key.- Parameters:
objectKey
-
-
handleCreation
protected T handleCreation(ObjectKey<T> objectKey)
Default implementation of how objects should be created. This implementation calls the ObjectCreator (objectkey.getObjectCreator()) to create the object and puts this object into the cache.- Parameters:
objectKey
- the objectkey- Returns:
- the created object which has been put into the cache
-
-