public abstract class AbstractNearCacheRecordStore<K,V,KS,R extends NearCacheRecord,NCRM extends NearCacheRecordMap<KS,R>> extends Object implements NearCacheRecordStore<K,V>, EvictionListener<KS,R>
Modifier and Type | Class and Description |
---|---|
protected class |
AbstractNearCacheRecordStore.MaxSizeEvictionChecker |
Modifier and Type | Field and Description |
---|---|
protected EvictionChecker |
evictionChecker |
protected EvictionPolicyEvaluator<KS,R> |
evictionPolicyEvaluator |
protected EvictionStrategy<KS,R,NCRM> |
evictionStrategy |
protected long |
maxIdleMillis |
protected MaxSizeChecker |
maxSizeChecker |
protected NearCacheConfig |
nearCacheConfig |
protected NearCacheStatsImpl |
nearCacheStats |
protected NCRM |
records |
protected static int |
REFERENCE_SIZE |
protected SerializationService |
serializationService |
protected long |
timeToLiveMillis |
NO_LISTENER
Constructor and Description |
---|
AbstractNearCacheRecordStore(NearCacheConfig nearCacheConfig,
NearCacheContext nearCacheContext) |
AbstractNearCacheRecordStore(NearCacheConfig nearCacheConfig,
NearCacheContext nearCacheContext,
NearCacheStatsImpl nearCacheStats) |
Modifier and Type | Method and Description |
---|---|
protected void |
checkAvailable() |
void |
clear()
Removes all stored values.
|
protected void |
clearRecords() |
protected EvictionChecker |
createEvictionChecker(NearCacheConfig nearCacheConfig) |
protected EvictionPolicyEvaluator<KS,R> |
createEvictionPolicyEvaluator(EvictionConfig evictionConfig) |
protected EvictionStrategy<KS,R,NCRM> |
createEvictionStrategy(EvictionConfig evictionConfig) |
protected abstract MaxSizeChecker |
createNearCacheMaxSizeChecker(EvictionConfig evictionConfig,
NearCacheConfig nearCacheConfig,
NearCacheContext nearCacheContext) |
protected abstract NCRM |
createNearCacheRecordMap(NearCacheConfig nearCacheConfig,
NearCacheContext nearCacheContext) |
protected V |
dataToValue(Data data) |
void |
destroy()
Clears the record store and destroys it.
|
protected void |
destroyStore() |
void |
doEviction()
Does eviction as specified configuration
EvictionConfig
in NearCacheConfig regardless from the max-size policy. |
void |
doEvictionIfRequired()
Does eviction as specified configuration
EvictionConfig
in NearCacheConfig . |
V |
get(K key)
Gets the value associated with the given
key . |
protected abstract long |
getKeyStorageMemoryCost(K key) |
NearCacheStats |
getNearCacheStats()
Get the
NearCacheStats instance to monitor this record store. |
protected abstract R |
getRecord(K key) |
protected abstract long |
getRecordStorageMemoryCost(R record) |
protected long |
getTotalStorageMemoryCost(K key,
R record) |
protected boolean |
isAvailable() |
protected boolean |
isEvictionEnabled() |
protected boolean |
isRecordExpired(R record) |
void |
onEvict(KS key,
R record)
Called when an
Evictable entry is evicted. |
protected void |
onGet(K key,
V value,
R record) |
protected void |
onGetError(K key,
V value,
R record,
Throwable error) |
protected void |
onPut(K key,
V value,
R record,
R oldRecord) |
protected void |
onPutError(K key,
V value,
R record,
R oldRecord,
Throwable error) |
protected void |
onRecordAccess(R record) |
protected void |
onRecordCreate(R record) |
protected void |
onRemove(K key,
R record,
boolean removed) |
protected void |
onRemoveError(K key,
R record,
boolean removed,
Throwable error) |
void |
put(K key,
V value)
Puts (associates) a value with the given
key . |
protected abstract R |
putRecord(K key,
R record) |
protected abstract void |
putToRecord(R record,
V value) |
protected abstract V |
recordToValue(R record) |
boolean |
remove(K key)
Removes the value associated with the given
key . |
protected abstract R |
removeRecord(K key) |
int |
size()
Gets the number of stored records.
|
protected Data |
toData(Object obj) |
protected V |
toValue(Object obj) |
protected Data |
valueToData(V value) |
protected abstract R |
valueToRecord(V value) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
doExpiration, selectToSave
protected static final int REFERENCE_SIZE
protected final long timeToLiveMillis
protected final long maxIdleMillis
protected final NearCacheConfig nearCacheConfig
protected final SerializationService serializationService
protected final NearCacheStatsImpl nearCacheStats
protected NCRM extends NearCacheRecordMap<KS,R> records
protected final MaxSizeChecker maxSizeChecker
protected final EvictionPolicyEvaluator<KS,R extends NearCacheRecord> evictionPolicyEvaluator
protected final EvictionChecker evictionChecker
protected final EvictionStrategy<KS,R extends NearCacheRecord,NCRM extends NearCacheRecordMap<KS,R>> evictionStrategy
public AbstractNearCacheRecordStore(NearCacheConfig nearCacheConfig, NearCacheContext nearCacheContext)
public AbstractNearCacheRecordStore(NearCacheConfig nearCacheConfig, NearCacheContext nearCacheContext, NearCacheStatsImpl nearCacheStats)
protected abstract MaxSizeChecker createNearCacheMaxSizeChecker(EvictionConfig evictionConfig, NearCacheConfig nearCacheConfig, NearCacheContext nearCacheContext)
protected abstract NCRM createNearCacheRecordMap(NearCacheConfig nearCacheConfig, NearCacheContext nearCacheContext)
protected abstract long getKeyStorageMemoryCost(K key)
protected abstract long getRecordStorageMemoryCost(R record)
protected void checkAvailable()
protected EvictionPolicyEvaluator<KS,R> createEvictionPolicyEvaluator(EvictionConfig evictionConfig)
protected EvictionChecker createEvictionChecker(NearCacheConfig nearCacheConfig)
protected EvictionStrategy<KS,R,NCRM> createEvictionStrategy(EvictionConfig evictionConfig)
protected boolean isAvailable()
protected boolean isRecordExpired(R record)
protected void onRecordCreate(R record)
protected void onRecordAccess(R record)
protected boolean isEvictionEnabled()
public void onEvict(KS key, R record)
EvictionListener
Evictable
entry is evicted.onEvict
in interface EvictionListener<KS,R extends NearCacheRecord>
key
- Accessor of the Evictable
entry
that is evicted.record
- Evictable
entry that is evicted.public V get(K key)
NearCacheRecordStore
key
.get
in interface NearCacheRecordStore<K,V>
key
- the key from which to get the associated value.key
.public void put(K key, V value)
NearCacheRecordStore
key
.put
in interface NearCacheRecordStore<K,V>
key
- the key to which the given value will be associated.value
- the value that will be associated with the key.public boolean remove(K key)
NearCacheRecordStore
key
.remove
in interface NearCacheRecordStore<K,V>
key
- the key from which the value will be removed.true
if the value was removed, otherwise false
.protected void clearRecords()
public void clear()
NearCacheRecordStore
clear
in interface NearCacheRecordStore<K,V>
protected void destroyStore()
public void destroy()
NearCacheRecordStore
destroy
in interface NearCacheRecordStore<K,V>
public int size()
NearCacheRecordStore
size
in interface NearCacheRecordStore<K,V>
public NearCacheStats getNearCacheStats()
NearCacheRecordStore
NearCacheStats
instance to monitor this record store.getNearCacheStats
in interface NearCacheRecordStore<K,V>
NearCacheStats
instance to monitor this record store.public void doEvictionIfRequired()
NearCacheRecordStore
EvictionConfig
in NearCacheConfig
.doEvictionIfRequired
in interface NearCacheRecordStore<K,V>
public void doEviction()
NearCacheRecordStore
EvictionConfig
in NearCacheConfig
regardless from the max-size policy.doEviction
in interface NearCacheRecordStore<K,V>
Copyright © 2016 Hazelcast, Inc.. All Rights Reserved.