|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.hazelcast.cache.impl.AbstractCacheRecordStore<R,CRM>
public abstract class AbstractCacheRecordStore<R extends CacheRecord,CRM extends SampleableCacheRecordMap<Data,R>>
Nested Class Summary | |
---|---|
protected class |
AbstractCacheRecordStore.MaxSizeEvictionChecker
|
Field Summary | |
---|---|
protected Map<CacheEventType,Set<CacheEventData>> |
batchEvent
|
protected CacheConfig |
cacheConfig
|
protected javax.cache.integration.CacheLoader |
cacheLoader
|
protected AbstractCacheService |
cacheService
|
protected javax.cache.integration.CacheWriter |
cacheWriter
|
protected static int |
DEFAULT_INITIAL_CAPACITY
|
protected javax.cache.expiry.ExpiryPolicy |
defaultExpiryPolicy
|
protected EvictionChecker |
evictionChecker
|
protected CacheEvictionConfig |
evictionConfig
|
protected EvictionPolicyEvaluator<Data,R> |
evictionPolicyEvaluator
|
protected EvictionStrategy<Data,R,CRM> |
evictionStrategy
|
protected boolean |
hasExpiringEntry
|
protected boolean |
isEventBatchingEnabled
|
protected boolean |
isEventsEnabled
|
protected CacheMaxSizeChecker |
maxSizeChecker
|
protected String |
name
|
protected NodeEngine |
nodeEngine
|
protected int |
partitionCount
|
protected int |
partitionId
|
protected CRM |
records
|
protected CacheStatisticsImpl |
statistics
|
Fields inherited from interface com.hazelcast.cache.impl.ICacheRecordStore |
---|
ONE_HUNDRED_PERCENT |
Constructor Summary | |
---|---|
AbstractCacheRecordStore(String name,
int partitionId,
NodeEngine nodeEngine,
AbstractCacheService cacheService)
|
Method Summary | ||
---|---|---|
R |
accessRecord(R record,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
long now)
|
|
void |
clear()
clears all internal data without publishing any events |
|
protected void |
closeListeners()
|
|
protected void |
closeResources()
|
|
protected boolean |
compare(Object v1,
Object v2)
|
|
boolean |
contains(Data key)
Determines if this store contains an entry for the specified key. |
|
protected abstract CacheEntryProcessorEntry |
createCacheEntryProcessorEntry(Data key,
R record,
long now,
int completionId)
|
|
protected CacheMaxSizeChecker |
createCacheMaxSizeChecker(int size,
CacheEvictionConfig.CacheMaxSizePolicy maxSizePolicy)
|
|
protected EvictionChecker |
createEvictionChecker(CacheEvictionConfig cacheEvictionConfig)
|
|
protected R |
createRecord(Data keyData,
Object value,
long expirationTime,
int completionId)
|
|
protected R |
createRecord(long expiryTime)
|
|
protected R |
createRecord(Object value,
long expiryTime)
|
|
protected abstract
|
createRecord(T value,
long creationTime,
long expiryTime)
|
|
protected abstract CRM |
createRecordCacheMap()
|
|
R |
createRecordWithExpiry(Data key,
Object value,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
long now,
boolean disableWriteThrough,
int completionId)
|
|
protected EvictionPolicyEvaluator<Data,R> |
creatEvictionPolicyEvaluator(CacheEvictionConfig cacheEvictionConfig)
|
|
protected EvictionStrategy<Data,R,CRM> |
creatEvictionStrategy(CacheEvictionConfig cacheEvictionConfig)
|
|
protected abstract R |
dataToRecord(Data data)
|
|
protected abstract
|
dataToValue(Data data)
|
|
protected void |
deleteAllCacheEntry(Set<Data> keys)
|
|
protected void |
deleteCacheEntry(Data key)
|
|
protected boolean |
deleteRecord(Data key,
int completionId)
|
|
void |
destroy()
Destroy is equivalent to below operations in the given order: clear all. close resources. unregister all listeners. |
|
int |
evictIfRequired()
Evict cache record store if eviction is required. |
|
protected long |
expiryPolicyToTTL(javax.cache.expiry.ExpiryPolicy expiryPolicy)
|
|
Object |
get(Data key,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
Gets the value to which the specified key is mapped, or null if this cache contains no mapping for the key. |
|
MapEntrySet |
getAll(Set<Data> keySet,
javax.cache.expiry.ExpiryPolicy expiryPolicy)
Gets a collection of entries from the store, returning them as Map of the values associated with the set of keys requested. |
|
Object |
getAndPut(Data key,
Object value,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
String caller,
int completionId)
Associates the specified value with the specified key in this cache, returning an existing value if one existed. |
|
Object |
getAndRemove(Data key,
String caller,
int completionId)
Atomically removes the entry for a key only if it is currently mapped to some value. |
|
Object |
getAndReplace(Data key,
Object value,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
String caller,
int completionId)
Atomically replaces the value for a given key if and only if there is a value currently mapped by the key. |
|
CacheStatisticsImpl |
getCacheStats()
Gets the Cache statistics associated with this CacheService . |
|
CacheConfig |
getConfig()
Gets the configuration of the cache that this store belongs to. |
|
protected javax.cache.expiry.ExpiryPolicy |
getExpiryPolicy(javax.cache.expiry.ExpiryPolicy expiryPolicy)
|
|
String |
getName()
Gets the name of the distributed object name of the cache. |
|
Map<Data,CacheRecord> |
getReadOnlyRecords()
Returns a readonly map of the internal key value store. |
|
CacheRecord |
getRecord(Data key)
Gets internal record of the store by key. |
|
Object |
invoke(Data key,
javax.cache.processor.EntryProcessor entryProcessor,
Object[] arguments,
int completionId)
Invokes an EntryProcessor against the Cache.Entry specified by
the provided key. |
|
boolean |
isEvictionEnabled()
|
|
protected boolean |
isEvictionRequired()
|
|
protected boolean |
isReadThrough()
|
|
protected boolean |
isStatisticsEnabled()
|
|
protected boolean |
isWriteThrough()
|
|
CacheKeyIteratorResult |
iterator(int tableIndex,
int size)
Starting from the provided table index, a set of keys are returned with a maximum size of size |
|
Set<Data> |
loadAll(Set<Data> keys,
boolean replaceExistingValues)
Synchronously loads the specified entries into the cache using the configured CacheLoader for the given keys. |
|
protected Map<Data,Object> |
loadAllCacheEntry(Set<Data> keys)
|
|
protected void |
onDeleteRecord(Data key,
R record,
Data dataValue,
boolean deleted)
|
|
protected void |
onDeleteRecordError(Data key,
R record,
Data dataValue,
boolean deleted,
Throwable error)
|
|
protected void |
onGet(Data key,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
Object value,
R record)
|
|
protected void |
onGetError(Data key,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
Object value,
R record,
Throwable error)
|
|
protected void |
onPut(Data key,
Object value,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
String caller,
boolean getValue,
boolean disableWriteThrough,
R record,
Object oldValue,
boolean isExpired,
boolean isNewPut,
boolean isSaveSucceed)
|
|
protected void |
onPutError(Data key,
Object value,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
String caller,
boolean getValue,
boolean disableWriteThrough,
R record,
Object oldValue,
boolean wouldBeNewPut,
Throwable error)
|
|
protected void |
onPutIfAbsent(Data key,
Object value,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
String caller,
boolean disableWriteThrough,
R record,
boolean isExpired,
boolean isSaveSucceed)
|
|
protected void |
onPutIfAbsentError(Data key,
Object value,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
String caller,
boolean disableWriteThrough,
R record,
Throwable error)
|
|
protected long |
onRecordAccess(R record,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
long now)
|
|
protected void |
onRemove(Data key,
Object value,
String caller,
boolean getValue,
R record,
boolean removed)
|
|
protected void |
onRemoveError(Data key,
Object value,
String caller,
boolean getValue,
R record,
boolean removed,
Throwable error)
|
|
protected void |
onReplace(Data key,
Object oldValue,
Object newValue,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
String caller,
boolean getValue,
R record,
boolean isExpired,
boolean replaced)
|
|
protected void |
onReplaceError(Data key,
Object oldValue,
Object newValue,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
String caller,
boolean getValue,
R record,
boolean isExpired,
boolean replaced,
Throwable error)
|
|
protected void |
onUpdateRecord(Data key,
R record,
Object value,
Data oldDataValue)
|
|
protected void |
onUpdateRecordError(Data key,
R record,
Object value,
Data newDataValue,
Data oldDataValue,
Throwable error)
|
|
boolean |
processExpiredEntry(Data key,
R record,
long now)
|
|
R |
processExpiredEntry(Data key,
R record,
long expiryTime,
long now)
|
|
protected void |
publishBatchedEvents(String cacheName,
CacheEventType cacheEventType,
int orderKey)
|
|
protected void |
publishEvent(CacheEventType eventType,
Data dataKey,
Data dataOldValue,
Data dataValue,
boolean isOldValueAvailable,
int completionId)
|
|
protected Object |
put(Data key,
Object value,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
String caller,
boolean getValue,
boolean disableWriteThrough,
int completionId)
|
|
protected Object |
put(Data key,
Object value,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
String caller,
boolean getValue,
int completionId)
|
|
void |
put(Data key,
Object value,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
String caller,
int completionId)
Associates the specified value with the specified key in this cache, returning an existing value if one existed. |
|
protected boolean |
putIfAbsent(Data key,
Object value,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
String caller,
boolean disableWriteThrough,
int completionId)
|
|
boolean |
putIfAbsent(Data key,
Object value,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
String caller,
int completionId)
Removes the mapping for a key from this cache if it is present. |
|
void |
putRecord(Data key,
CacheRecord record)
Associates the specified record with the specified key. |
|
Object |
readThroughCache(Data key)
|
|
R |
readThroughRecord(Data key,
long now)
|
|
protected abstract Data |
recordToData(R record)
|
|
protected abstract
|
recordToValue(R record)
|
|
boolean |
remove(Data key,
Object value,
String caller,
int completionId)
Atomically removes the mapping for a key only if currently mapped to the given value. |
|
boolean |
remove(Data key,
String caller,
int completionId)
Removes the mapping for a key from this cache if it is present. |
|
void |
removeAll(Set<Data> keys,
int completionId)
records of keys will be deleted one by one and will publish a REMOVE event for each key. |
|
CacheRecord |
removeRecord(Data key)
Removes the record for a key. |
|
boolean |
replace(Data key,
Object value,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
String caller,
int completionId)
Atomically replaces the entry for a key only if currently mapped to some value. |
|
boolean |
replace(Data key,
Object oldValue,
Object newValue,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
String caller,
int completionId)
Atomically replaces the entry for a key only if currently mapped to a given value. |
|
void |
setRecord(Data key,
CacheRecord record)
Associates the specified record with the specified key. |
|
int |
size()
Calculates the entry size of this store which reflects the partition size of the cache. |
|
protected Data |
toData(Object obj)
|
|
protected Data |
toEventData(Object obj)
|
|
protected abstract Data |
toHeapData(Object obj)
|
|
protected R |
toRecord(Object obj)
|
|
protected
|
toValue(Object obj)
|
|
protected javax.cache.expiry.ExpiryPolicy |
ttlToExpirePolicy(long ttl)
|
|
protected long |
updateAccessDuration(R record,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
long now)
|
|
protected void |
updateGetAndPutStat(boolean isPutSucceed,
boolean getValue,
boolean oldValueNull,
long start)
|
|
protected void |
updateHasExpiringEntry(R record)
|
|
protected R |
updateRecord(Data key,
R record,
Object value,
int completionId)
|
|
boolean |
updateRecordWithExpiry(Data key,
Object value,
R record,
javax.cache.expiry.ExpiryPolicy expiryPolicy,
long now,
boolean disableWriteThrough,
int completionId)
|
|
protected void |
updateReplaceStat(boolean result,
boolean isHit,
long start)
|
|
protected abstract
|
valueToData(T value)
|
|
protected abstract
|
valueToRecord(T value)
|
|
void |
writeThroughCache(Data key,
Object value)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final int DEFAULT_INITIAL_CAPACITY
protected final String name
protected final int partitionId
protected final int partitionCount
protected final NodeEngine nodeEngine
protected final AbstractCacheService cacheService
protected final CacheConfig cacheConfig
protected CRM extends SampleableCacheRecordMap<Data,R> records
protected CacheStatisticsImpl statistics
protected javax.cache.integration.CacheLoader cacheLoader
protected javax.cache.integration.CacheWriter cacheWriter
protected boolean isEventsEnabled
protected boolean isEventBatchingEnabled
protected javax.cache.expiry.ExpiryPolicy defaultExpiryPolicy
protected final CacheEvictionConfig evictionConfig
protected volatile boolean hasExpiringEntry
protected final Map<CacheEventType,Set<CacheEventData>> batchEvent
protected final CacheMaxSizeChecker maxSizeChecker
protected final EvictionPolicyEvaluator<Data,R extends CacheRecord> evictionPolicyEvaluator
protected final EvictionChecker evictionChecker
protected final EvictionStrategy<Data,R extends CacheRecord,CRM extends SampleableCacheRecordMap<Data,R>> evictionStrategy
Constructor Detail |
---|
public AbstractCacheRecordStore(String name, int partitionId, NodeEngine nodeEngine, AbstractCacheService cacheService)
Method Detail |
---|
protected boolean isReadThrough()
protected boolean isWriteThrough()
protected boolean isStatisticsEnabled()
protected abstract CRM createRecordCacheMap()
protected abstract CacheEntryProcessorEntry createCacheEntryProcessorEntry(Data key, R record, long now, int completionId)
protected abstract <T> R createRecord(T value, long creationTime, long expiryTime)
protected abstract <T> Data valueToData(T value)
protected abstract <T> T dataToValue(Data data)
protected abstract <T> R valueToRecord(T value)
protected abstract <T> T recordToValue(R record)
protected abstract Data recordToData(R record)
protected abstract R dataToRecord(Data data)
protected abstract Data toHeapData(Object obj)
protected CacheMaxSizeChecker createCacheMaxSizeChecker(int size, CacheEvictionConfig.CacheMaxSizePolicy maxSizePolicy)
protected EvictionPolicyEvaluator<Data,R> creatEvictionPolicyEvaluator(CacheEvictionConfig cacheEvictionConfig)
protected EvictionChecker createEvictionChecker(CacheEvictionConfig cacheEvictionConfig)
protected EvictionStrategy<Data,R,CRM> creatEvictionStrategy(CacheEvictionConfig cacheEvictionConfig)
protected boolean isEvictionRequired()
protected void updateHasExpiringEntry(R record)
public boolean isEvictionEnabled()
public int evictIfRequired()
ICacheRecordStore
Eviction logic is handled as specified EvictionPolicy
in CacheConfig
for this record store
evictIfRequired
in interface ICacheRecordStore
protected Data toData(Object obj)
protected <T> T toValue(Object obj)
protected R toRecord(Object obj)
protected Data toEventData(Object obj)
protected javax.cache.expiry.ExpiryPolicy getExpiryPolicy(javax.cache.expiry.ExpiryPolicy expiryPolicy)
public boolean processExpiredEntry(Data key, R record, long now)
public R processExpiredEntry(Data key, R record, long expiryTime, long now)
public R accessRecord(R record, javax.cache.expiry.ExpiryPolicy expiryPolicy, long now)
protected void updateGetAndPutStat(boolean isPutSucceed, boolean getValue, boolean oldValueNull, long start)
protected long updateAccessDuration(R record, javax.cache.expiry.ExpiryPolicy expiryPolicy, long now)
protected long onRecordAccess(R record, javax.cache.expiry.ExpiryPolicy expiryPolicy, long now)
protected void updateReplaceStat(boolean result, boolean isHit, long start)
protected void publishEvent(CacheEventType eventType, Data dataKey, Data dataOldValue, Data dataValue, boolean isOldValueAvailable, int completionId)
protected void publishBatchedEvents(String cacheName, CacheEventType cacheEventType, int orderKey)
protected boolean compare(Object v1, Object v2)
protected long expiryPolicyToTTL(javax.cache.expiry.ExpiryPolicy expiryPolicy)
protected javax.cache.expiry.ExpiryPolicy ttlToExpirePolicy(long ttl)
protected R createRecord(long expiryTime)
protected R createRecord(Object value, long expiryTime)
protected R createRecord(Data keyData, Object value, long expirationTime, int completionId)
public R createRecordWithExpiry(Data key, Object value, javax.cache.expiry.ExpiryPolicy expiryPolicy, long now, boolean disableWriteThrough, int completionId)
protected void onUpdateRecord(Data key, R record, Object value, Data oldDataValue)
protected void onUpdateRecordError(Data key, R record, Object value, Data newDataValue, Data oldDataValue, Throwable error)
protected R updateRecord(Data key, R record, Object value, int completionId)
public boolean updateRecordWithExpiry(Data key, Object value, R record, javax.cache.expiry.ExpiryPolicy expiryPolicy, long now, boolean disableWriteThrough, int completionId)
protected void onDeleteRecord(Data key, R record, Data dataValue, boolean deleted)
protected void onDeleteRecordError(Data key, R record, Data dataValue, boolean deleted, Throwable error)
protected boolean deleteRecord(Data key, int completionId)
public R readThroughRecord(Data key, long now)
public Object readThroughCache(Data key) throws javax.cache.integration.CacheLoaderException
javax.cache.integration.CacheLoaderException
public void writeThroughCache(Data key, Object value) throws javax.cache.integration.CacheWriterException
javax.cache.integration.CacheWriterException
protected void deleteCacheEntry(Data key)
protected void deleteAllCacheEntry(Set<Data> keys)
protected Map<Data,Object> loadAllCacheEntry(Set<Data> keys)
public CacheRecord getRecord(Data key)
ICacheRecordStore
getRecord
in interface ICacheRecordStore
key
- the key to the entry.
CacheRecord
instance mapped.public void setRecord(Data key, CacheRecord record)
ICacheRecordStore
setRecord
in interface ICacheRecordStore
key
- the key to the entry.record
- the value to be associated with the specified key.public void putRecord(Data key, CacheRecord record)
ICacheRecordStore
putRecord
in interface ICacheRecordStore
key
- the key to the entry.record
- the value to be associated with the specified key.public CacheRecord removeRecord(Data key)
ICacheRecordStore
removeRecord
in interface ICacheRecordStore
key
- the key to the entry.
protected void onGet(Data key, javax.cache.expiry.ExpiryPolicy expiryPolicy, Object value, R record)
protected void onGetError(Data key, javax.cache.expiry.ExpiryPolicy expiryPolicy, Object value, R record, Throwable error)
public Object get(Data key, javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICacheRecordStore
null
if this cache contains no mapping for the key.
If the cache is configured to use read-through, and get would return null
because the entry is missing from the cache, the Cache's CacheLoader
is called in an attempt to load the entry.
get
in interface ICacheRecordStore
key
- the key whose associated value is to be returned.expiryPolicy
- custom expiry policy or null to use configured default value.
public boolean contains(Data key)
ICacheRecordStore
More formally, returns true if and only if this store contains a mapping for a key k such that key.equals(k) (There can be at most one such mapping.)
contains
in interface ICacheRecordStore
key
- key whose presence in this store is to be tested.
protected void onPut(Data key, Object value, javax.cache.expiry.ExpiryPolicy expiryPolicy, String caller, boolean getValue, boolean disableWriteThrough, R record, Object oldValue, boolean isExpired, boolean isNewPut, boolean isSaveSucceed)
protected void onPutError(Data key, Object value, javax.cache.expiry.ExpiryPolicy expiryPolicy, String caller, boolean getValue, boolean disableWriteThrough, R record, Object oldValue, boolean wouldBeNewPut, Throwable error)
protected Object put(Data key, Object value, javax.cache.expiry.ExpiryPolicy expiryPolicy, String caller, boolean getValue, boolean disableWriteThrough, int completionId)
protected Object put(Data key, Object value, javax.cache.expiry.ExpiryPolicy expiryPolicy, String caller, boolean getValue, int completionId)
public void put(Data key, Object value, javax.cache.expiry.ExpiryPolicy expiryPolicy, String caller, int completionId)
ICacheRecordStore
If the cache previously contained a mapping for
the key, the old value is replaced by the specified value. (A cache
c is said to contain a mapping for a key k if and only
if c.contains(k)
would return
true.)
The previous value is returned, or null if there was no value associated with the key previously.
put
in interface ICacheRecordStore
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.expiryPolicy
- custom expiry policy or null to use configured default value.caller
- uuid of the calling node or client.public Object getAndPut(Data key, Object value, javax.cache.expiry.ExpiryPolicy expiryPolicy, String caller, int completionId)
ICacheRecordStore
If the cache previously contained a mapping for
the key, the old value is replaced by the specified value. (A cache
c is said to contain a mapping for a key k if and only
if c.contains(k)
would return
true.)
The previous value is returned, or null if there was no value associated with the key previously.
getAndPut
in interface ICacheRecordStore
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.expiryPolicy
- custom expiry policy or null to use configured default value.caller
- uuid of the calling node or client.
protected void onPutIfAbsent(Data key, Object value, javax.cache.expiry.ExpiryPolicy expiryPolicy, String caller, boolean disableWriteThrough, R record, boolean isExpired, boolean isSaveSucceed)
protected void onPutIfAbsentError(Data key, Object value, javax.cache.expiry.ExpiryPolicy expiryPolicy, String caller, boolean disableWriteThrough, R record, Throwable error)
protected boolean putIfAbsent(Data key, Object value, javax.cache.expiry.ExpiryPolicy expiryPolicy, String caller, boolean disableWriteThrough, int completionId)
public boolean putIfAbsent(Data key, Object value, javax.cache.expiry.ExpiryPolicy expiryPolicy, String caller, int completionId)
ICacheRecordStore
More formally, if this cache contains a mapping from key k to
value v such that
(key==null ? k==null : key.equals(k))
, that mapping is removed.
(The cache can contain at most one such mapping.)
Returns true if this cache previously associated the key, or false if the cache contained no mapping for the key.
The cache will not contain a mapping for the specified key once the call returns.
putIfAbsent
in interface ICacheRecordStore
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.expiryPolicy
- custom expiry policy or null to use configured default value.caller
- uuid of the calling node or client.
protected void onReplace(Data key, Object oldValue, Object newValue, javax.cache.expiry.ExpiryPolicy expiryPolicy, String caller, boolean getValue, R record, boolean isExpired, boolean replaced)
protected void onReplaceError(Data key, Object oldValue, Object newValue, javax.cache.expiry.ExpiryPolicy expiryPolicy, String caller, boolean getValue, R record, boolean isExpired, boolean replaced, Throwable error)
public boolean replace(Data key, Object value, javax.cache.expiry.ExpiryPolicy expiryPolicy, String caller, int completionId)
ICacheRecordStore
This is equivalent to
if (cache.containsKey(key)) {
cache.put(key, value);
return true;
} else {
return false;
}
except that the action is performed atomically.
replace
in interface ICacheRecordStore
key
- the key with which the specified value is associated.value
- the value to be associated with the specified key.expiryPolicy
- custom expiry policy or null to use configured default value.caller
- uuid of the calling node or client.
public boolean replace(Data key, Object oldValue, Object newValue, javax.cache.expiry.ExpiryPolicy expiryPolicy, String caller, int completionId)
ICacheRecordStore
This is equivalent to:
if (cache.containsKey(key) && equals(cache.get(key), oldValue)) {
cache.put(key, newValue);
return true;
} else {
return false;
}
except that the action is performed atomically.
replace
in interface ICacheRecordStore
key
- key with which the specified value is associated.oldValue
- value expected to be associated with the specified key.newValue
- value to be associated with the specified key.expiryPolicy
- custom expiry policy or null to use configured default value.caller
- uuid of the calling node or client.
public Object getAndReplace(Data key, Object value, javax.cache.expiry.ExpiryPolicy expiryPolicy, String caller, int completionId)
ICacheRecordStore
This is equivalent to
if (cache.containsKey(key)) {
V oldValue = cache.get(key);
cache.put(key, value);
return oldValue;
} else {
return null;
}
except that the action is performed atomically.
getAndReplace
in interface ICacheRecordStore
key
- key with which the specified value is associated.value
- value to be associated with the specified key.expiryPolicy
- custom expiry policy or null to use configured default value.caller
- uuid of the calling node or client.
protected void onRemove(Data key, Object value, String caller, boolean getValue, R record, boolean removed)
protected void onRemoveError(Data key, Object value, String caller, boolean getValue, R record, boolean removed, Throwable error)
public boolean remove(Data key, String caller, int completionId)
ICacheRecordStore
More formally, if this cache contains a mapping from key k to
value v such that
(key==null ? k==null : key.equals(k))
, that mapping is removed.
(The cache can contain at most one such mapping.)
Returns true if this cache previously associated the key, or false if the cache contained no mapping for the key.
The cache will not contain a mapping for the specified key once the call returns.
remove
in interface ICacheRecordStore
key
- key whose mapping is to be removed from the cache.caller
- uuid of the calling node or client.
public boolean remove(Data key, Object value, String caller, int completionId)
ICacheRecordStore
This is equivalent to:
if (cache.containsKey(key) && equals(cache.get(key), oldValue) {
cache.remove(key);
return true;
} else {
return false;
}
except that the action is performed atomically.
remove
in interface ICacheRecordStore
key
- key whose mapping is to be removed from the cache.value
- value expected to be associated with the specified key.caller
- uuid of the calling node or client.
public Object getAndRemove(Data key, String caller, int completionId)
ICacheRecordStore
This is equivalent to:
if (cache.containsKey(key)) {
V oldValue = cache.get(key);
cache.remove(key);
return oldValue;
} else {
return null;
}
except that the action is performed atomically.
getAndRemove
in interface ICacheRecordStore
key
- key with which the specified value is associated.caller
- uuid of the calling node or client.
public void clear()
ICacheRecordStore
clear
in interface ICacheRecordStore
public MapEntrySet getAll(Set<Data> keySet, javax.cache.expiry.ExpiryPolicy expiryPolicy)
ICacheRecordStore
Map
of the values associated with the set of keys requested.
If the cache is configured read-through, and a get for a key would
return null because an entry is missing from the cache, the Cache's
CacheLoader
is called in an attempt to load the entry. If an
entry cannot be loaded for a given key, the key will not be present in
the returned Map.
getAll
in interface ICacheRecordStore
keySet
- keys whose associated values are to be returned.expiryPolicy
- custom expiry policy or null to use configured default value.
public void removeAll(Set<Data> keys, int completionId)
ICacheRecordStore
removeAll
in interface ICacheRecordStore
keys
- set of keys to be cleaned.public Set<Data> loadAll(Set<Data> keys, boolean replaceExistingValues)
ICacheRecordStore
CacheLoader
for the given keys.
If an entry for a key already exists in the cache, a value will be loaded
if and only if replaceExistingValues
is true. If no loader
is configured for the cache, no objects will be loaded.
loadAll
in interface ICacheRecordStore
keys
- the keys to be loaded.replaceExistingValues
- when true, existing values in the cache will
be replaced by those loaded from a CacheLoader.
public CacheKeyIteratorResult iterator(int tableIndex, int size)
ICacheRecordStore
size
iterator
in interface ICacheRecordStore
tableIndex
- initial table index.size
- maximum key set size.
CacheKeyIteratorResult
which wraps keys and last tableIndex.public Object invoke(Data key, javax.cache.processor.EntryProcessor entryProcessor, Object[] arguments, int completionId)
ICacheRecordStore
EntryProcessor
against the Cache.Entry
specified by
the provided key. If an Cache.Entry
does not exist for the specified key,
an attempt is made to load it (if a loader is configured) or a surrogate
Cache.Entry
, consisting of the key with a null value is used instead.
invoke
in interface ICacheRecordStore
key
- the key of the entry.entryProcessor
- the EntryProcessor
to be invoked.arguments
- additional arguments to be passed to the
EntryProcessor
.
EntryProcessor
implementation.public int size()
ICacheRecordStore
size
in interface ICacheRecordStore
public CacheStatisticsImpl getCacheStats()
ICacheRecordStore
CacheService
.
getCacheStats
in interface ICacheRecordStore
CacheStatisticsImpl
cache statistics.public CacheConfig getConfig()
ICacheRecordStore
getConfig
in interface ICacheRecordStore
CacheConfig
public String getName()
ICacheRecordStore
getName
in interface ICacheRecordStore
public Map<Data,CacheRecord> getReadOnlyRecords()
ICacheRecordStore
getReadOnlyRecords
in interface ICacheRecordStore
public void destroy()
ICacheRecordStore
destroy
in interface ICacheRecordStore
protected void closeListeners()
protected void closeResources()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |