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, setWaitForResponse
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
public 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_PUSH
evictionStrategy
- 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 AbstractMap
key
- key for the value
.value
- object(~ entry)txn
- transactiontimeToLive
- time to leave in master cachepublic int size()
AbstractMap
public void clear()
Cache
public void clear(boolean clearMaster)
IMap
public boolean containsKey(Object key)
Cache
containsKey
in interface Cache
containsKey
in interface Map
key
- key whose presence in this cache is to be tested.true
, if the cache contains the specified key.public boolean containsValue(Object value)
Cache
containsValue
in interface Cache
containsValue
in interface Map
value
- value whose presence in this cache is to be tested.true
, if the cache contains the specified value.public Collection values()
Cache
public Set entrySet()
Cache
public Set keySet()
Cache
public void addListener(CacheListener listener)
Cache
addListener
in interface Cache
listener
- call back CacheListener
public boolean evict(Object key)
Cache
public CacheEntry getCacheEntry(Object key)
Cache
getCacheEntry
in interface Cache
key
- key whose associated value is to be returned.public void load(Object key) throws CacheException
AbstractMap
load
in interface Cache
load
in class AbstractMap
key
- key whose associated value is to be loaded.CacheException
- error accord while loadingpublic void loadAll(Collection keys) throws CacheException
AbstractMap
loadAll
in interface Cache
loadAll
in class AbstractMap
keys
- 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)
Cache
public void removeListener(CacheListener listener)
Cache
removeListener
in interface Cache
listener
- the CacheListener
to removepublic void notify(RemoteEvent remoteEvent) throws UnknownEventException, RemoteException
RemoteEventListener
The 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 RemoteEventListener
remoteEvent
- the remote event that occurredUnknownEventException
- the recipient does not recognize the combination of event
identifier and event sourceRemoteException
protected Object internalRemove(Object key, Transaction txn, long waitForResponse)
AbstractMap
internalRemove
in class AbstractMap
key
- 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)
AbstractMap
internalGet
in class AbstractMap
key
- key whose mapping is to be removed from the map.waitForResponse
- to wait for responsepublic void notify(LeaseRenewalEvent event)
LeaseListener
LeaseRenewalManager
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 LeaseListener
event
- 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.