com.hazelcast.cache.impl
public interface ICacheRecordStore
ICacheRecordStore
is the core contract providing internal functionality to
ICache
implementations on partition scope. All of the ICache methods actually
map to a method on this interface through Hazelcast's RPC mechanism. Hazelcast
Operation
is sent to the relevant partition to be executed and the final
results are returned to the callers.
For each partition, there is only one ICacheRecordStore
in the cluster.
Implementations of this interface may provide different internal data persistence like on-heap storage.
Each expirible cache entry is actually aData
, CacheRecord
pair.
Key type: always serialized form of Data
.
Value types: depend on the configuration.
CacheRecordStore
Modifier and Type | Field and Description |
---|---|
static int |
ONE_HUNDRED_PERCENT |
Modifier and Type | Method and Description |
---|---|
void |
clear()
clears all internal data without publishing any events
|
boolean |
contains(Data key)
Determines if this store contains an entry for the specified key.
|
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.
|
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.
|
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. |
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. |
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.
|
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.
|
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.
|
static final int ONE_HUNDRED_PERCENT
Object get(Data key, javax.cache.expiry.ExpiryPolicy expiryPolicy)
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.
key
- the key whose associated value is to be returned.expiryPolicy
- custom expiry policy or null to use configured default value.void put(Data key, Object value, javax.cache.expiry.ExpiryPolicy expiryPolicy, String caller, int completionId)
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.
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.Object getAndPut(Data key, Object value, javax.cache.expiry.ExpiryPolicy expiryPolicy, String caller, int completionId)
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.
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.boolean putIfAbsent(Data key, Object value, javax.cache.expiry.ExpiryPolicy expiryPolicy, String caller, int completionId)
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.
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.Object getAndRemove(Data key, String caller, int completionId)
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.key
- key with which the specified value is associated.caller
- uuid of the calling node or client.boolean remove(Data key, String caller, int completionId)
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.
key
- key whose mapping is to be removed from the cache.caller
- uuid of the calling node or client.boolean remove(Data key, Object value, String caller, int completionId)
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.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.boolean replace(Data key, Object value, javax.cache.expiry.ExpiryPolicy expiryPolicy, String caller, int completionId)
This is equivalent to
if (cache.containsKey(key)) {
cache.put(key, value);
return true;
} else {
return false;
}
except that the action is performed atomically.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.boolean replace(Data key, Object oldValue, Object newValue, javax.cache.expiry.ExpiryPolicy expiryPolicy, String caller, int completionId)
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.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.Object getAndReplace(Data key, Object value, javax.cache.expiry.ExpiryPolicy expiryPolicy, String caller, int completionId)
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.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.boolean contains(Data key)
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.)
key
- key whose presence in this store is to be tested.MapEntrySet getAll(Set<Data> keySet, javax.cache.expiry.ExpiryPolicy expiryPolicy)
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.
keySet
- keys whose associated values are to be returned.expiryPolicy
- custom expiry policy or null to use configured default value.int size()
void clear()
void removeAll(Set<Data> keys, int completionId)
keys
- set of keys to be cleaned.void destroy()
CacheConfig getConfig()
CacheConfig
String getName()
Map<Data,CacheRecord> getReadOnlyRecords()
CacheRecord getRecord(Data key)
key
- the key to the entry.CacheRecord
instance mapped.void setRecord(Data key, CacheRecord record)
key
- the key to the entry.record
- the value to be associated with the specified key.void putRecord(Data key, CacheRecord record)
key
- the key to the entry.record
- the value to be associated with the specified key.CacheRecord removeRecord(Data key)
key
- the key to the entry.CacheKeyIteratorResult iterator(int tableIndex, int size)
size
tableIndex
- initial table index.size
- maximum key set size.CacheKeyIteratorResult
which wraps keys and last tableIndex.Object invoke(Data key, javax.cache.processor.EntryProcessor entryProcessor, Object[] arguments, int completionId)
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.
key
- the key of the entry.entryProcessor
- the EntryProcessor
to be invoked.arguments
- additional arguments to be passed to the
EntryProcessor
.EntryProcessor
implementation.Set<Data> loadAll(Set<Data> keys, boolean replaceExistingValues)
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.
keys
- the keys to be loaded.replaceExistingValues
- when true, existing values in the cache will
be replaced by those loaded from a CacheLoader.CacheStatisticsImpl getCacheStats()
CacheService
.CacheStatisticsImpl
cache statistics.int evictIfRequired()
Eviction logic is handled as specified EvictionPolicy
in CacheConfig
for this record store
Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.