public class LocalRegionCache extends Object implements RegionCache
RegionCache implementation
based on a topic to distribute cache updates.| Modifier and Type | Field and Description |
|---|---|
protected ConcurrentMap<Object,Value> |
cache |
protected MapConfig |
config |
protected MessageListener<Object> |
messageListener |
protected ITopic<Object> |
topic |
protected Comparator |
versionComparator |
| Constructor and Description |
|---|
LocalRegionCache(String name,
HazelcastInstance hazelcastInstance,
CacheDataDescription metadata) |
LocalRegionCache(String name,
HazelcastInstance hazelcastInstance,
CacheDataDescription metadata,
boolean withTopic) |
| Modifier and Type | Method and Description |
|---|---|
Map |
asMap() |
void |
clear() |
boolean |
contains(Object key) |
protected Object |
createMessage(Object key,
Object value,
Object currentVersion) |
protected MessageListener<Object> |
createMessageListener() |
Object |
get(Object key) |
long |
getSizeInMemory() |
boolean |
put(Object key,
Object value,
Object currentVersion) |
boolean |
remove(Object key) |
long |
size() |
SoftLock |
tryLock(Object key,
Object version) |
void |
unlock(Object key,
SoftLock lock) |
boolean |
update(Object key,
Object value,
Object currentVersion,
Object previousVersion,
SoftLock lock) |
protected final MessageListener<Object> messageListener
protected final ConcurrentMap<Object,Value> cache
protected final Comparator versionComparator
protected MapConfig config
public LocalRegionCache(String name, HazelcastInstance hazelcastInstance, CacheDataDescription metadata)
name - the name for this region cache, which is also used to retrieve configuration/topichazelcastInstance - the HazelcastInstance to which this region cache belongs, used to retrieve
configuration and to lookup an ITopic to register a MessageListener
with (optional)metadata - metadata describing the cached data, used to compare data versions (optional)public LocalRegionCache(String name, HazelcastInstance hazelcastInstance, CacheDataDescription metadata, boolean withTopic)
name - the name for this region cache, which is also used to retrieve configuration/topichazelcastInstance - the HazelcastInstance to which this region cache belongs, used to retrieve
configuration and to lookup an ITopic to register a MessageListener
with if withTopic is true (optional)metadata - metadata describing the cached data, used to compare data versions (optional)withTopic - true to register a MessageListener with the ITopic whose name
matches this region cache if a HazelcastInstance was provided to look
up the topic; otherwise, false not to register a listener even if an instance
was providedpublic Object get(Object key)
get in interface RegionCachepublic boolean put(Object key, Object value, Object currentVersion)
put in interface RegionCachepublic boolean update(Object key, Object value, Object currentVersion, Object previousVersion, SoftLock lock)
update in interface RegionCacheprotected MessageListener<Object> createMessageListener()
public boolean remove(Object key)
remove in interface RegionCachepublic SoftLock tryLock(Object key, Object version)
tryLock in interface RegionCachepublic void unlock(Object key, SoftLock lock)
unlock in interface RegionCachepublic boolean contains(Object key)
contains in interface RegionCachepublic void clear()
clear in interface RegionCachepublic long size()
size in interface RegionCachepublic long getSizeInMemory()
getSizeInMemory in interface RegionCachepublic Map asMap()
asMap in interface RegionCacheCopyright © 2015 Hazelcast, Inc.. All Rights Reserved.