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,Expirable> |
cache |
protected MapConfig |
config |
protected HazelcastInstance |
hazelcastInstance |
protected AtomicLong |
markerIdCounter |
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 txTimestamp) |
long |
getSizeInMemory() |
boolean |
insert(Object key,
Object value,
Object currentVersion) |
protected void |
maybeInvalidate(Object messageObject) |
protected void |
maybeNotifyTopic(Object key,
Object value,
Object version) |
boolean |
put(Object key,
Object value,
long txTimestamp,
Object version) |
boolean |
remove(Object key) |
long |
size() |
SoftLock |
tryLock(Object key,
Object version) |
void |
unlock(Object key,
SoftLock lock) |
boolean |
update(Object key,
Object newValue,
Object newVersion,
SoftLock softLock) |
protected final HazelcastInstance hazelcastInstance
protected final MessageListener<Object> messageListener
protected final ConcurrentMap<Object,Expirable> cache
protected final Comparator versionComparator
protected final AtomicLong markerIdCounter
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, long txTimestamp)
get
in interface RegionCache
public boolean insert(Object key, Object value, Object currentVersion)
insert
in interface RegionCache
public boolean put(Object key, Object value, long txTimestamp, Object version)
put
in interface RegionCache
public boolean update(Object key, Object newValue, Object newVersion, SoftLock softLock)
update
in interface RegionCache
protected MessageListener<Object> createMessageListener()
public boolean remove(Object key)
remove
in interface RegionCache
public SoftLock tryLock(Object key, Object version)
tryLock
in interface RegionCache
public void unlock(Object key, SoftLock lock)
unlock
in interface RegionCache
public boolean contains(Object key)
contains
in interface RegionCache
public void clear()
clear
in interface RegionCache
public long size()
size
in interface RegionCache
public long getSizeInMemory()
getSizeInMemory
in interface RegionCache
public Map asMap()
asMap
in interface RegionCache
protected void maybeInvalidate(Object messageObject)
Copyright © 2016 Hazelcast, Inc.. All Rights Reserved.