public class HazelcastCache extends Object implements Cache
Uses a Hazelcast map and a Hazelcast multimap, defaulting to the names "com.threecrickets.prudence.prudence.cache" and "com.threecrickets.prudence.prduence.cacheTags" respectively. Refer to Hazelcast documentation for instructions on how to configure them.
Constructor and Description |
---|
HazelcastCache()
Constructor.
|
HazelcastCache(com.hazelcast.core.HazelcastInstance hazelcast)
Constructor.
|
HazelcastCache(com.hazelcast.core.HazelcastInstance hazelcast,
String cacheName,
String cacheTagsName)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
CacheEntry |
fetch(String key)
Fetches an entry from the cache if it's there and has not yet expired.
|
void |
invalidate(String tag)
Makes sure that all tagged entries are un-fetchable.
|
void |
prune()
Removes expired cache entries.
|
void |
reset()
Removes all entries in the cache.
|
void |
store(String key,
CacheEntry entry)
Stores an entry in the cache.
|
public HazelcastCache()
public HazelcastCache(com.hazelcast.core.HazelcastInstance hazelcast)
hazelcast
- The hazelcast instance or null to use the instance named
"com.threecrickets.prudence.default"public HazelcastCache(com.hazelcast.core.HazelcastInstance hazelcast, String cacheName, String cacheTagsName)
hazelcast
- The Hazelcast instance or null to use the instance named
"com.threecrickets.prudence.default"cacheName
- The Hazelcast map name for the cachecacheTagsName
- The Hazelcast map name for the tag mappublic void store(String key, CacheEntry entry)
Cache
CacheEntry.getExpirationDate()
, although it may very well
be un-fetchable sooner.
Keys are unique to the cache. Storing for a key that already exists will replace the entry if it exists.
public CacheEntry fetch(String key)
Cache
public void invalidate(String tag)
Cache
invalidate
in interface Cache
tag
- The cache tagpublic void prune()
Cache
Copyright © 2009-2016 Three Crickets LLC.