Package alpine.server.cache
Class AbstractCacheManager
java.lang.Object
alpine.server.cache.AbstractCacheManager
- Direct Known Subclasses:
CacheManager
AbstractCacheManager provides a per-class object cache.
- Since:
- 1.5.0
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractCacheManager(long expiresAfter, TimeUnit timeUnit, long maxSize) Constructs a new AbstractCacheManager object. -
Method Summary
Modifier and TypeMethodDescription<T> TRetrieves an object (of the specified class) from cache.<T> TRetrieves an object (of the specified class) from cache.voidmaintenance(Class clazz) Performs maintenance on the cache.voidAdds an object to cache.voidRemove an object from cache.
-
Constructor Details
-
AbstractCacheManager
Constructs a new AbstractCacheManager object.- Parameters:
expiresAfter- the number of time units to expire aftertimeUnit- the unit of measurementmaxSize- the maximum size of the cache (per object type)
-
-
Method Details
-
get
Retrieves an object (of the specified class) from cache.- Type Parameters:
T- the object type- Parameters:
clazz- the class of the object to retrieve from cachekey- the unique identifier of the object to retrieve from cache- Returns:
- the cached object (if found) or null if not found
- Since:
- 1.5.0
-
get
Retrieves an object (of the specified class) from cache.- Type Parameters:
T- the object type- Parameters:
clazz- the class of the object to retrieve from cachekey- the unique identifier of the object to retrieve from cachemappingFunction- the function to call if the object is not present in cache- Returns:
- the cached object (if found) or null if not found and a mappingFunction is not specified
- Since:
- 1.5.0
-
put
Adds an object to cache.- Parameters:
key- the unique identifier of the object to put into cacheobject- the object to put into cache.- Since:
- 1.5.0
-
remove
Remove an object from cache.- Parameters:
clazz- the class of the object to remove from cachekey- the unique identifier of the object to remove from cache
-
maintenance
Performs maintenance on the cache. Maintenance is automatically carried out and use of this method is normally not required. However, if maintenance must be performed immediately, use of this method may be called.- Parameters:
clazz- the class of the object to perform maintenance on- Since:
- 1.5.0
-