Package com.j_spaces.map
Interface IMap
- All Known Implementing Classes:
AbstractMap,GSMapImpl,MapCache
Notice: since 7.0 this API is internal and might be subject to changes in future versions.
Use GigaMap instead.
This interface extends Map interface and provides Map interface to GigaSpaces.
The IMap interface can be used in remote , embedded and Master-Local Topology.
The Map
interface provides three collection views, which allow a map's contents to be viewed as a set of
keys, collection of values, or set of key-value mappings.
You can associate attributes to a key and values (e.g. security tags, special user profiles, etc.), and set time for entries to exist in the cache until eviction.
- Since:
- 3.2
- Version:
- 6.0
- See Also:
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoidclear(boolean clearMaster) The clear method will remove all objects from the cache including the key and the associated value.Returns the object that is associated withkeyin this cache.get(Object key, Transaction txn, long waitForResponse, int readModifiers) Returns the object that is associated withkeyin this cache.Returns the Local Space proxy if exists.Returns the Master Space proxy.longReturns how long cached objects will live in the cache.Deprecated.use explicit transaction insteadlongReturns how long wait for response for theput(java.lang.Object, java.lang.Object, long),get(java.lang.Object, long)andremove(java.lang.Object, long)calls.booleanCheck if using optimistic locking.Putsvalueto the cache with specifiedkeyfortimeToLivemilliseconds to live in the cache.Putsvalueto the cache with specifiedkeyfortimeToLivemilliseconds to live in the cache.put(Object key, Object value, Transaction txn, long timeToLive) Putsvalueto the cache with specifiedkeyfortimeToLivemilliseconds to live in the cache.put(Object key, Object value, Transaction txn, long timeToLive, long waitForResponse) Putsvalueto the cache with specifiedkeyfortimeToLivemilliseconds to live in the cache.voidputAll(Map map, Transaction txn, long timeToLive) Copies all of the mappings from the specified map to the cache.Removes the mapping for thiskeyfrom this cache.remove(Object key, Transaction txn, long waitForResponse) Removes the mapping for thiskeyfrom this cache.voidsetTimeToLive(long millisecond) Sets the duration that entries will stay in the cache.voidsetTransaction(Transaction transaction) Deprecated.use explicit transaction insteadvoidsetVersioned(boolean versioned) Sets optimistic locking mode.voidsetWaitForResponse(long timeout) Sets the timeout for theput(java.lang.Object, java.lang.Object, long),get(java.lang.Object, long)andremove(java.lang.Object, long)calls to wait for response.Methods inherited from interface com.j_spaces.javax.cache.Cache
addListener, clear, containsKey, containsValue, entrySet, equals, evict, get, getAll, getCacheEntry, hashCode, isEmpty, keySet, load, loadAll, peek, put, putAll, remove, removeListener, size, valuesMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Method Details
-
setTimeToLive
void setTimeToLive(long millisecond) Sets the duration that entries will stay in the cache.- Parameters:
millisecond- how long entries will live in the cache, in milliseconds
-
getTimeToLive
long getTimeToLive()Returns how long cached objects will live in the cache.- Returns:
- how long entries will live in the cache, in milliseconds
-
setWaitForResponse
void setWaitForResponse(long timeout) Sets the timeout for theput(java.lang.Object, java.lang.Object, long),get(java.lang.Object, long)andremove(java.lang.Object, long)calls to wait for response.- Parameters:
timeout- time to wait for response
-
getWaitForResponse
long getWaitForResponse()Returns how long wait for response for theput(java.lang.Object, java.lang.Object, long),get(java.lang.Object, long)andremove(java.lang.Object, long)calls.- Returns:
- time to wait for response
-
put
Putsvalueto the cache with specifiedkeyfortimeToLivemilliseconds to live in the cache.- Parameters:
key- key for thevaluevalue- object(~ entry)timeToLive- time to keep object in this cache, in milliseconds- Returns:
- previous value associated with specified key, or null if there was no mapping for key.
-
put
Putsvalueto the cache with specifiedkeyfortimeToLivemilliseconds to live in the cache.- Parameters:
key- key for thevaluevalue- object(~ entry)timeToLive- time to keep object in this cache, in milliseconds- Returns:
- previous value associated with specified key, or null if there was no mapping for key.
-
put
Putsvalueto the cache with specifiedkeyfortimeToLivemilliseconds to live in the cache.- Parameters:
key- key for thevaluevalue- object(~ entry)txn- the transaction object, if any, under which to perform the puttimeToLive- time to keep object in this cache, in milliseconds- Returns:
- previous value associated with specified key, or null if there was no mapping for key.
- Since:
- 6.0
-
put
Putsvalueto the cache with specifiedkeyfortimeToLivemilliseconds to live in the cache.- Parameters:
key- key for thevaluevalue- object(~ entry)txn- the transaction object, if any, under which to perform the puttimeToLive- time to keep object in this cache, in millisecondswaitForResponse- time to wait for response- Returns:
- previous value associated with specified key, or null if there was no mapping for key.
- Since:
- 7.1
-
putAll
Copies all of the mappings from the specified map to the cache.- Parameters:
map- A map of key and values to be copy into the cachetxn- the transaction object, if any, under which to perform the puttimeToLive- time to keep object in this cache, in milliseconds- Since:
- 6.0
-
get
Returns the object that is associated withkeyin this cache. Client will wait at mostwaitForResponsemilliseconds for get call to return.- Parameters:
key- key whose associated value is to be returned.waitForResponse- time to wait for response- Returns:
- Returns the object that is associated with the key
-
get
Returns the object that is associated withkeyin this cache. Client will wait at mostwaitForResponsemilliseconds for get call to return.- Parameters:
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 ofReadModifiers.- Returns:
- Returns the object that is associated with the key
- Since:
- 6.0
-
remove
Removes the mapping for thiskeyfrom this cache. Client will wait at mostwaitForResponsemilliseconds for get call to return.- Parameters:
key- key whose associated value is to be returned.waitForResponse- time to wait for response- Returns:
- The removed object
-
remove
Removes the mapping for thiskeyfrom this cache. Client will wait at mostwaitForResponsemilliseconds for get call to return.- Parameters:
key- key whose associated value is to be returned.txn- the transaction object, if any, under which to perform the removewaitForResponse- time to wait for response- Returns:
- The removed object
- Since:
- 6.0
-
clear
void clear(boolean clearMaster) The clear method will remove all objects from the cache including the key and the associated value.- Parameters:
clearMaster- iftrueclear also master, whenfalseequals to clear()
-
setTransaction
Deprecated.use explicit transaction insteadSet current transaction, all the map calls will be performed under this transaction. Setting tonullwill turn all the following map calls to be with transaction. In order toIMap 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- Parameters:
transaction- active transaction ornull
-
getTransaction
Deprecated.use explicit transaction insteadReturns active transaction ornullif no transaction defined.- Returns:
- Transaction
-
getMasterSpace
IJSpace getMasterSpace()Returns the Master Space proxy.- Returns:
- the master space proxy
-
getLocalSpace
IJSpace getLocalSpace()Returns the Local Space proxy if exists.- Returns:
- the local space proxy
-
setVersioned
void setVersioned(boolean versioned) Sets optimistic locking mode.- Parameters:
versioned-trueif optimistic locking is needed
-
isVersioned
boolean isVersioned()Check if using optimistic locking.- Returns:
trueif using optimistic locking
-