public final class MapCache extends AbstractMap implements RemoteEventListener, LeaseListener
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_MAX_CONNECTION_RETRY
The default number of retires to reconnect to server when fault is discovered.
|
_compression, _entryInfos, _isVersioned, _spaceProxy, _timeout, _timeToLive, _transaction, NONE_COMPRESSION, ZIP_COMPRESSION| Constructor and Description |
|---|
MapCache(IJSpace space,
boolean isVersioned,
int updateMode,
EvictionStrategy evictionStrategy,
boolean putFirst,
int sizeLimit,
int compression)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(CacheListener listener)
Add a listener to the list of cache listeners.
Optional, not supported by all the implementations, currently supported only by local cache. |
void |
clear()
The clear method will remove all objects from the cache including the key and the associated
value.
|
void |
clear(boolean clearMaster)
The clear method will remove all objects from the cache including the key and the associated
value.
|
boolean |
containsKey(Object key)
Returns true if the cache contains the specified key.
|
boolean |
containsValue(Object value)
Returns true if this cache maps one or more keys to the specified value.
|
Set |
entrySet()
Returns a set view of the objects currently contained in the cache.
|
boolean |
evict(Object key)
The evict method will remove object from the cache the matches the provided key.
|
protected void |
finalize() |
CacheEntry |
getCacheEntry(Object key)
Returns the CacheEntry object associated with the object identified by "key".
|
protected Object |
internalGet(Object key,
Transaction txn,
long waitForResponse,
int readModifiers)
Gets the mapping for this key from this map if it is present.
|
protected Object |
internalPut(Object key,
Object value,
Transaction txn,
long timeToLive,
long timeout) |
protected Object |
internalRemove(Object key,
Transaction txn,
long waitForResponse)
Removes the mapping for this key from this map if it is present.
|
Set |
keySet()
Returns a set view of the keys currently contained in the cache.
|
void |
load(Object key)
The load method provides a means to "pre load" the cache.
|
void |
loadAll(Collection keys)
The loadAll method provides a means to "pre load" objects into the cache.
|
void |
notify(LeaseRenewalEvent event)
Called by the
LeaseRenewalManager when it cannot renew a lease that it is
managing, and the lease's desired expiration time has not yet been reached. |
void |
notify(RemoteEvent remoteEvent)
Notify the listener about an event.
|
Object |
peek(Object key)
The peek method will return the object associated with "key" if it currently exists (and is
valid) in the cache.
|
void |
removeListener(CacheListener listener)
Remove a listener from the list of cache listeners.
Optional, not supported by all the implementations, currently supported only by local cache |
int |
size()
Returns the size of this map.
|
Collection |
values()
Returns a collection view of the values contained in this cache.
|
buildEnvelope, get, get, get, getAll, getLocalSpace, getMasterSpace, getTimeToLive, getTransaction, getWaitForResponse, isEmpty, isVersioned, log, log, put, put, put, put, put, putAll, putAll, remove, remove, remove, setTimeToLive, setTransaction, setVersioned, setWaitForResponseclone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAllpublic static final int DEFAULT_MAX_CONNECTION_RETRY
public MapCache(IJSpace space, boolean isVersioned, int updateMode, EvictionStrategy evictionStrategy, boolean putFirst, int sizeLimit, int compression) throws RemoteException
space - proxy to spaceisVersioned - true if a version should be kept for the valuesupdateMode - SpaceURL.UPDATE_MODE_PULL or SpaceURL.UPDATE_MODE_PUSHevictionStrategy - eviction strategy to use in CacheputFirst - true if an unloaded value should be kept in cache on its
first putRemoteException - might be thrown in case of network exception or server connection
failprotected Object internalPut(Object key, Object value, Transaction txn, long timeToLive, long timeout)
internalPut in class AbstractMapkey - key for the value.value - object(~ entry)txn - transactiontimeToLive - time to leave in master cachepublic int size()
AbstractMappublic void clear()
Cachepublic void clear(boolean clearMaster)
IMappublic boolean containsKey(Object key)
CachecontainsKey in interface CachecontainsKey in interface Mapkey - key whose presence in this cache is to be tested.true, if the cache contains the specified key.public boolean containsValue(Object value)
CachecontainsValue in interface CachecontainsValue in interface Mapvalue - value whose presence in this cache is to be tested.true, if the cache contains the specified value.public Collection values()
Cachepublic Set entrySet()
Cachepublic Set keySet()
Cachepublic void addListener(CacheListener listener)
CacheaddListener in interface Cachelistener - call back CacheListenerpublic boolean evict(Object key)
Cachepublic CacheEntry getCacheEntry(Object key)
CachegetCacheEntry in interface Cachekey - key whose associated value is to be returned.public void load(Object key) throws CacheException
AbstractMapload in interface Cacheload in class AbstractMapkey - key whose associated value is to be loaded.CacheException - error accord while loadingpublic void loadAll(Collection keys) throws CacheException
AbstractMaploadAll in interface CacheloadAll in class AbstractMapkeys - keys' Collection whose associated value to be loaded using the associated
CacheLoader if this cache doesn't contain it.CacheException - error accord while loadingpublic Object peek(Object key)
Cachepublic void removeListener(CacheListener listener)
CacheremoveListener in interface Cachelistener - the CacheListener to removepublic void notify(RemoteEvent remoteEvent) throws UnknownEventException, RemoteException
RemoteEventListenerThe call to notify is synchronous to allow the party making the call to know if the call succeeded. However, it is not part of the semantics of the call that the notification return can be delayed while the recipient of the call reacts to the occurrence of the event. Simply put, the best strategy on the part of the recipient is to note the occurrence in some way and then return from the notify method as quickly as possible.
UnknownEventException is thrown when the recipient does not recognize the combination of the event identifier and the event source as something in which it is interested. Throwing this exception has the effect of asking the sender to not send further notifications of this kind of event from this source in the future.
notify in interface RemoteEventListenerremoteEvent - the remote event that occurredUnknownEventException - the recipient does not recognize the combination of event
identifier and event sourceRemoteExceptionprotected Object internalRemove(Object key, Transaction txn, long waitForResponse)
AbstractMapinternalRemove in class AbstractMapkey - key whose mapping is to be removed from the map.waitForResponse - to wait for responseprotected Object internalGet(Object key, Transaction txn, long waitForResponse, int readModifiers)
AbstractMapinternalGet in class AbstractMapkey - key whose mapping is to be removed from the map.waitForResponse - to wait for responsepublic void notify(LeaseRenewalEvent event)
LeaseListenerLeaseRenewalManager when it cannot renew a lease that it is
managing, and the lease's desired expiration time has not yet been reached. Note that,
prior to invoking this method, the LeaseRenewalManager removes the affected
lease from the managed set of leases. Note also that, because of the reentrancy guarantee
made by the LeaseRenewalManager, new leases can be safely added by this method.
notify in interface LeaseListenerevent - instance of LeaseRenewalEvent containing information about the lease
that the LeaseRenewalManager was unable to renew, as well as
information about the condition that made the LeaseRenewalManager fail
to renew the leaseCopyright © GigaSpaces.