public class CacheManager<K,V> extends Object
<logger name="jkniv.utils.CACHE" additivity="false"> <level value="debug" /> <appender-ref ref="console" /> </logger>
Constructor and Description |
---|
CacheManager()
Create a new cache manager with 5 seconds for initial delay to first execution
and 5 minutes for period between successive executions.
|
CacheManager(long period)
Create a new cache manager with 5 seconds for initial delay to first execution
and configurable parameter for
period to between successive executions. |
CacheManager(long initialDelay,
long period)
Create a new cache manager with configurable
initialDelay and period . |
CacheManager(long delay,
long period,
CachePolicy policy)
Create a new cache manager with configurable
initialDelay and period . |
Modifier and Type | Method and Description |
---|---|
Cacheable<K,V> |
add(String key)
Create a new Memory cache to be managed with a default policy
|
Cacheable<K,V> |
add(String key,
Cacheable<K,V> cache)
Add a new cache for manager
|
CachePolicy |
add(String policyName,
CachePolicy policy)
Add new policy with specific name
|
Cacheable<K,V> |
add(String key,
String policyName,
Cacheable<K,V> cache)
Add a new cache for manager
|
void |
cancel() |
void |
pooling() |
int |
size()
Returns the number of caches in this manager
|
long |
total()
Returns the total of elements in all cache entries in this manager.
|
public CacheManager()
public CacheManager(long period)
period
to between successive executions.period
- the period between successive executionspublic CacheManager(long initialDelay, long period)
initialDelay
and period
.initialDelay
- seconds to the time to delay first executionperiod
- seconds to the period between successive executionspublic CacheManager(long delay, long period, CachePolicy policy)
initialDelay
and period
.delay
- seconds to the time to delay first executionperiod
- seconds to the period between successive executionspolicy
- default policy for cache entries add(String, Cacheable)
public CachePolicy add(String policyName, CachePolicy policy)
policyName
- name of policypolicy
- policy to manager a cachepolicyName
,
or null
if there was no mapping for policyName
public Cacheable<K,V> add(String key, Cacheable<K,V> cache)
key
- cache identifycache
- the managed cachekey
,
or null
if there was no mapping for key
public Cacheable<K,V> add(String key, String policyName, Cacheable<K,V> cache)
key
- cache identifypolicyName
- name of policy, the cache no exist a default cache is associatedcache
- the managed cachekey
,
or null
if there was no mapping for key
public Cacheable<K,V> add(String key)
key
- cache identifypublic void pooling()
public void cancel()
public long total()
public int size()
Copyright © 2012–2020 jkniv, copyleft code. All rights reserved.