Interface GigaMap
- All Known Implementing Classes:
DefaultGigaMap
IMap and Cache implementation.
Though this interface has a single implementation it is still important to work against the interface as it allows for simpler testing and mocking.
Transaction management is implicit and works in a declarative manner. Operations do not accept
a transaction object, and will automatically use the TransactionProvider in order to
acquire the current running transaction. If there is no current running transaction the operation
will be executed without a transaction.
- Author:
- kimchy
-
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.Returns the object that is associated withkeyin this cache.Returns the current running transaction.longReturns the default time to live of entries in the map.longReturns the default wait for response value for entries in the map.getMap()Returns theIMapused by this GigaMap implementation to delegate different space operations.Returns the transaction provider allowing accessing the current running transaction.booleanReturnstrueif the given key is locked.Locks the given key for any updates.Locks the given key for any updates.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, long timeToLive, LockHandle lockHandle) Putsvalueto the cache with specifiedkeyfortimeToLivemilliseconds to live in the cache.put(Object key, Object value, LockHandle lockHandle) Putsvalueto the cache with specifiedkey.voidCopies all of the mappings from the specified map to the cache.voidputAndUnlock(Object key, Object value) Unlocks the given key and puts the given value in a single operation.Removes the mapping for thiskeyfrom this cache.remove(Object key, long waitForResponse, LockHandle lockHandle) Removes the mapping for thiskeyfrom this cache.voidUnlocks the given lock on the keyMethods 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
-
getMap
IMap getMap()Returns theIMapused by this GigaMap implementation to delegate different space operations.Allows to execute map operations that are not exposed by this interface, as well as using it as a parameter to other low level GigaSpace components.
If a transaction object is required for low level operations (as low level operations do not have declarative transaction ex) the
getTxProvider()should be used to acquire the current running transaction. -
getTxProvider
TransactionProvider getTxProvider()Returns the transaction provider allowing accessing the current running transaction. Allows to execute low levelIMapoperations that requires explicit transaction object. -
getCurrentTransaction
Transaction getCurrentTransaction()Returns the current running transaction. Can benullif no transaction is in progress. -
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.waitForResponse- time to wait for responsemodifiers- one or a union ofReadModifiers.- Returns:
- Returns the object that is associated with the 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)timeToLive- time to keep object in this cache, in millisecondstimeout- A timeout to use if the object is locked under a transaction (in milliseconds)- Returns:
- previous value associated with specified key, or null if there was no mapping for key.
-
put
Putsvalueto the cache with specifiedkey.- Parameters:
key- key for thevaluevalue- object(~ entry)lockHandle- If the key is locked, will perform the operation within the same lock- 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 millisecondslockHandle- If the key is locked, will perform the operation within the same lock- Returns:
- previous value associated with specified key, or null if there was no mapping for key.
-
putAll
Copies all of the mappings from the specified map to the cache.- Parameters:
t- A map of key and values to be copy into the cache
-
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.waitForResponse- time to wait for responselockHandle- If the key is locked, will perform the operation within the same lock- Returns:
- The removed object
-
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, whenfalsesame asMap.clear().)
-
lock
Locks the given key for any updates. Returns aLockHandlethat can be bused to perform specific updates under the same lock (by callingput(Object, Object, org.openspaces.core.map.LockHandle)for example).Will use the configured default lock time to live and default waiting for lock timeout values. By default the lock time to live is 60 seconds and waiting for lock timeout is 10 seconds.
- Parameters:
key- The key to lock- Returns:
- LockHandle that can be used to perform operations under the given lock
-
lock
Locks the given key for any updates. Returns aLockHandlethat can be used to perform specific updates under the same lock (by using the transaction object stored within it).- Parameters:
key- The key to locklockTimeToLive- The lock time to live (in milliseconds)waitingForLockTimeout- The time to wait for an already locked lock- Returns:
- LockHandle that can be used to perform operations under the given lock
-
unlock
Unlocks the given lock on the key- Parameters:
key- The key to unlock
-
isLocked
Returnstrueif the given key is locked. Otherwise returnsfalse.- Parameters:
key- The key to check if it locked or not.- Returns:
trueif the given key is locked or not.
-
putAndUnlock
Unlocks the given key and puts the given value in a single operation.- Parameters:
key- The key to unlock and put the value invalue- The value to put after unlocking the key
-
getDefaultTimeToLive
long getDefaultTimeToLive()Returns the default time to live of entries in the map. -
getDefaultWaitForResponse
long getDefaultWaitForResponse()Returns the default wait for response value for entries in the map.
-