public interface CachePool
The CachePool is typically implemented as a Polygene Extension, and is an optional extension in the persistence subsystem of Polygene. If a Cache Extension is not provided, caching will be turned off. However, since caching operate on EntityStore level, and is an optional component at that, just because you have defined a Cache Extension does not necessary mean that your system will use it. Check the EntityStore implementations for details if they are Cache enabled. Most EntityStore implementations has this enabled, often via the MapEntityStore and JSONMapEntityStore SPI.
NOTE: Make sure that there is a match between the fetchCache and returnCache methods, to ensure no memory leakage occur. Also remember that if the reference count reaches zero, the CachePool will destroy the Cache as soon as possible and a new fetchCache will return an empty one.
Modifier and Type | Method and Description |
---|---|
<T> Cache<T> |
fetchCache(String cacheId,
Class<T> valueType)
Fetches a cache from the pool.
|
void |
returnCache(Cache<?> cache)
Returns the cache back to the pool.
|
<T> Cache<T> fetchCache(String cacheId, Class<T> valueType)
T
- Value typecacheId
- The reference of the cache. If the same id is given as a previous fetch, the same cache will be
returned.valueType
- Value typevoid returnCache(Cache<?> cache)
cache
- The cache to return to the pool.