Modifier and Type | Field and Description |
---|---|
protected StorageType |
_compression |
protected MapVersionTable |
_entryInfos |
protected boolean |
_isVersioned |
protected ISpaceProxy |
_spaceProxy |
protected long |
_timeout |
protected long |
_timeToLive |
protected Transaction |
_transaction |
static int |
NONE_COMPRESSION |
static int |
ZIP_COMPRESSION |
Constructor and Description |
---|
AbstractMap(IJSpace space,
long timeToLive,
Transaction txn,
int compression,
boolean isVersioned)
AbstractMap constructor.
|
Modifier and Type | Method and Description |
---|---|
protected SpaceMapEntry |
buildEnvelope(Object key,
Object value,
String cacheID)
Build Envelope using ClientUIDHandler utility class and adds the version if needed.
|
Object |
get(Object key)
The get method will return, from the cache, the object associated with the argument "key".
|
Object |
get(Object key,
long waitForResponse)
Returns the object that is associated with
key in this cache. |
Object |
get(Object key,
Transaction txn,
long waitForResponse,
int readModifiers)
Returns the object that is associated with
key in this cache. |
Map |
getAll(Collection keys)
The getAll method will return, from the cache, a Map of the objects associated with the
Collection of keys in argument "keys".
|
IJSpace |
getLocalSpace()
Returns the Local Space proxy if exists.
|
IJSpace |
getMasterSpace()
Returns the Master Space proxy.
|
long |
getTimeToLive()
Returns how long cached objects will live in the cache.
|
Transaction |
getTransaction()
Returns active transaction or
null if no transaction defined. |
long |
getWaitForResponse()
Returns how long wait for response for the
IMap.put(java.lang.Object, java.lang.Object, long) , IMap.get(java.lang.Object, long) and IMap.remove(java.lang.Object, long)
calls. |
protected abstract Object |
internalGet(Object key,
Transaction txn,
long waitForResponse,
int readModifiers)
Gets the mapping for this key from this map if it is present.
|
protected abstract Object |
internalPut(Object key,
Object value,
Transaction txn,
long timeToLive,
long timeout) |
protected abstract Object |
internalRemove(Object key,
Transaction txn,
long waitForResponse)
Removes the mapping for this key from this map if it is present.
|
boolean |
isEmpty()
Return true if entrySet().isEmpty() return true.
|
boolean |
isVersioned()
Check if using optimistic locking.
|
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.
|
protected void |
log(String description) |
protected void |
log(String description,
Exception ex) |
Object |
put(Object key,
Object value)
The put method adds the object "value" to the cache identified by the object "key".
|
Object |
put(Object key,
Object value,
long timeToLive)
Puts
value to the cache with specified key for
timeToLive milliseconds to live in the cache. |
Object |
put(Object key,
Object value,
long timeToLive,
long timeout)
Puts
value to the cache with specified key for
timeToLive milliseconds to live in the cache. |
Object |
put(Object key,
Object value,
Transaction txn,
long timeToLive)
Puts
value to the cache with specified key for
timeToLive milliseconds to live in the cache. |
Object |
put(Object key,
Object value,
Transaction txn,
long timeToLive,
long timeout)
Puts
value to the cache with specified key for
timeToLive milliseconds to live in the cache. |
void |
putAll(Map map)
Copies all of the mappings from the specified map to the cache.
|
void |
putAll(Map map,
Transaction txn,
long timeToLive)
Copies all of the mappings from the specified map to the cache.
|
Object |
remove(Object key)
The remove method will delete the object from the cache including the key, the associated
value and the associated CacheStatistics object.
|
Object |
remove(Object key,
long waitForResponse)
Removes the mapping for this
key from this cache. |
Object |
remove(Object key,
Transaction txn,
long waitForResponse)
Removes the mapping for this
key from this cache. |
void |
setTimeToLive(long millisecond)
Sets the duration that entries will stay in the cache.
|
void |
setTransaction(Transaction transaction)
Set current transaction, all the map calls will be performed under this transaction.
|
void |
setVersioned(boolean versioned)
Sets optimistic locking mode.
|
void |
setWaitForResponse(long timeout)
Sets the timeout for the
IMap.put(java.lang.Object, java.lang.Object, long) , IMap.get(java.lang.Object, long) and IMap.remove(java.lang.Object, long) calls to wait for
response. |
int |
size()
Returns the size of this map.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addListener, clear, containsKey, containsValue, entrySet, equals, evict, getCacheEntry, hashCode, keySet, peek, removeListener, values
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
public static final int NONE_COMPRESSION
public static final int ZIP_COMPRESSION
protected Transaction _transaction
protected long _timeToLive
protected long _timeout
protected ISpaceProxy _spaceProxy
protected final StorageType _compression
protected boolean _isVersioned
protected MapVersionTable _entryInfos
public AbstractMap(IJSpace space, long timeToLive, Transaction txn, int compression, boolean isVersioned)
space
- Space proxy or DCache proxy.timeToLive
- Time to live for value
object in cache.txn
- if not null
all operation will be executed with the desired
transaction.compression
- NONE = 0 , ZIP = 1isVersioned
- true
if versioned
To set new transaction use: setTransaction(txn) To reset the transaction
use: setTransaction(null) To get the current transaction use:
getTransaction()public final void setVersioned(boolean versioned)
setVersioned
in interface IMap
versioned
- true
if optimistic locking is neededpublic final boolean isVersioned()
isVersioned
in interface IMap
true
if using optimistic lockingpublic final void setTimeToLive(long millisecond)
setTimeToLive
in interface IMap
millisecond
- how long entries will live in the cache, in millisecondspublic final long getTimeToLive()
getTimeToLive
in interface IMap
public final void setWaitForResponse(long timeout)
IMap.put(java.lang.Object, java.lang.Object, long)
, IMap.get(java.lang.Object, long)
and IMap.remove(java.lang.Object, long)
calls to wait for
response.setWaitForResponse
in interface IMap
timeout
- time to wait for responsepublic final long getWaitForResponse()
IMap.put(java.lang.Object, java.lang.Object, long)
, IMap.get(java.lang.Object, long)
and IMap.remove(java.lang.Object, long)
calls.getWaitForResponse
in interface IMap
protected abstract Object internalPut(Object key, Object value, Transaction txn, long timeToLive, long timeout) throws CacheException
key
- key for the value
.value
- object(~ entry)txn
- transactiontimeToLive
- time to leave in master cacheCacheException
protected abstract Object internalGet(Object key, Transaction txn, long waitForResponse, int readModifiers) throws CacheException
key
- key whose mapping is to be removed from the map.waitForResponse
- to wait for responseCacheException
protected abstract Object internalRemove(Object key, Transaction txn, long waitForResponse) throws CacheException
key
- key whose mapping is to be removed from the map.waitForResponse
- to wait for responseCacheException
public final Object put(Object key, Object value)
public final Object put(Object key, Object value, long timeToLive)
value
to the cache with specified key
for
timeToLive
milliseconds to live in the cache.public Object put(Object key, Object value, long timeToLive, long timeout)
IMap
value
to the cache with specified key
for
timeToLive
milliseconds to live in the cache.public final Object put(Object key, Object value, Transaction txn, long timeToLive)
IMap
value
to the cache with specified key
for
timeToLive
milliseconds to live in the cache.put
in interface IMap
key
- key for the value
value
- object(~ entry)txn
- the transaction object, if any, under which to perform the puttimeToLive
- time to keep object in this cache, in millisecondspublic final Object put(Object key, Object value, Transaction txn, long timeToLive, long timeout)
value
to the cache with specified key
for
timeToLive
milliseconds to live in the cache.put
in interface IMap
key
- key for the value
value
- object(~ entry)txn
- the transaction object, if any, under which to perform the puttimeToLive
- time to keep object in this cache, in millisecondstimeout
- time to wait for responsepublic void putAll(Map map)
public void putAll(Map map, Transaction txn, long timeToLive)
public Map getAll(Collection keys) throws CacheException
getAll
in interface Cache
keys
- keys whose associated values are to be returned.CacheException
- error accord while loadingpublic Object get(Object key)
public Object get(Object key, long waitForResponse)
key
in this cache. Client will wait
at most waitForResponse
milliseconds for get call to return.public Object get(Object key, Transaction txn, long waitForResponse, int readModifiers)
key
in this cache. Client will wait
at most waitForResponse
milliseconds for get call to return.get
in interface IMap
key
- key whose associated value is to be returned.txn
- the transaction object, if any, under which to perform the getwaitForResponse
- time to wait for responsereadModifiers
- one or a union of ReadModifiers
.public int size()
public final boolean isEmpty()
public Object remove(Object key)
public Object remove(Object key, long waitForResponse)
key
from this cache. Client will wait at most
waitForResponse
milliseconds for get call to return.public Object remove(Object key, Transaction txn, long waitForResponse)
key
from this cache. Client will wait at most
waitForResponse
milliseconds for get call to return.public final void setTransaction(Transaction transaction)
null
will turn all the following map calls to be with transaction.
In order to
IMap map = ... ;
TransactionManager tm = ... ;
Transaction.Created created = TransactionFactory#create(tm, 10000);
map.setTransaction(Created.transaction)
map.put( "key1", "value1"); // under transaction
map.put( "key2", "value2"); // under transaction
Created.transaction.commit();
map.setTransaction( null);
map.remove( "key2"); // not under transaction
setTransaction
in interface IMap
transaction
- active transaction or null
public final Transaction getTransaction()
null
if no transaction defined.getTransaction
in interface IMap
public void load(Object key) throws CacheException
load
in interface Cache
key
- key whose associated value is to be loaded.CacheException
- error accord while loadingpublic void loadAll(Collection keys) throws CacheException
loadAll
in interface Cache
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 final IJSpace getMasterSpace()
getMasterSpace
in interface IMap
public final IJSpace getLocalSpace()
getLocalSpace
in interface IMap
protected SpaceMapEntry buildEnvelope(Object key, Object value, String cacheID)
protected void log(String description)
Copyright © GigaSpaces.