Package com.j_spaces.map
Class GSMapImpl
java.lang.Object
com.j_spaces.map.AbstractMap
com.j_spaces.map.GSMapImpl
This class provides an implementation to GigaSpaces IMap interface, for Distributed Caching using
Map API. Simply call Map.get and Map.put methods to store and retrieve values
into or from the cache.- Version:
- 4.0
- Author:
- Igor Goldenberg
-
Nested Class Summary
-
Field Summary
Fields inherited from class com.j_spaces.map.AbstractMap
_compression, _entryInfos, _isVersioned, _spaceProxy, _timeout, _timeToLive, _transaction, NONE_COMPRESSION, ZIP_COMPRESSION -
Constructor Summary
ConstructorsModifierConstructorDescriptionGSMap constructor.GSMap constructor.GSMap constructor.protectedGSMapImpl(IJSpace space, long timeToLive, Transaction txn, int compress) GSMapImpl constructor.GSMapImpl(IJSpace space, Transaction txn) GSMap constructor. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddListener(CacheListener listener) Unsupported Operation! Add a listener to the list of cache listeners.
Optional, not supported by all the implementations, currently supported only by local cache.voidclear()The clear method will remove all objects from the cache including the key and the associated value.voidclear(boolean clearMaster) The clear method will remove all objects from the cache including the key and the associated value.booleancontainsKey(Object key) Returns true if the cache contains the specified key.booleancontainsValue(Object value) Returns true if this cache maps one or more keys to the specified value.entrySet()Returns a set view of the objects currently contained in the cache.final booleanThe evict method will remove object from the cache the matches the provided key.final CacheEntrygetCacheEntry(Object key) Returns the CacheEntry object associated with the object identified by "key".protected ObjectinternalGet(Object key, Transaction txn, long waitForResponse, int readModifiers) Gets the mapping for this key from this map if it is present.protected ObjectinternalGet(Object key, Transaction txn, long waitForResponse, int readModifiers, boolean isRemove) Gets or Removes the mapping for this key from this map if present (optional operation).protected ObjectinternalPut(Object key, Object value, Transaction txn, long timeToLive, long timeout) Putsvalueto the cache with specifiedkeyandattributesfortimeToLivemilliseconds to live in the cache.protected ObjectinternalRemove(Object key, Transaction txn, long waitForResponse) Removes the mapping for this key from this map if it is present.keySet()Returns a set view of the keys currently contained in the cache.The peek method will return the object associated with "key" if it currently exists (and is valid) in the cache.voidremoveListener(CacheListener listener) Unsupported Operation! Remove a listener from the list of cache listeners.
Optional, not supported by all the implementations, currently supported only by local cachevalues()Returns a collection view of the values contained in this cache.Methods inherited from class com.j_spaces.map.AbstractMap
buildEnvelope, get, get, get, getAll, getLocalSpace, getMasterSpace, getTimeToLive, getTransaction, getWaitForResponse, isEmpty, isVersioned, load, loadAll, log, log, put, put, put, put, put, putAll, putAll, remove, remove, remove, setTimeToLive, setTransaction, setVersioned, setWaitForResponse, sizeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
GSMapImpl
GSMapImpl constructor. _serializationType- Parameters:
space- Space proxy or DCache proxy.timeToLive- Time to live forvalueobject in cache, use -1 for default value.txn- if notnullall operation will be executed with the desired transaction.compress- the compress level can be 1-9 To set new transaction use: setTransaction(txn) To reset the transaction use: setTransaction(null) To get the current transaction use: getTransaction()
-
GSMapImpl
GSMap constructor.- Parameters:
space- Space proxy or DCache proxy.
-
GSMapImpl
GSMap constructor.- Parameters:
space- Space proxy or DCache proxy.timeToLive- Time to live forvalueobject in cache.
-
GSMapImpl
GSMap constructor.- Parameters:
space- Space proxy or DCache proxy.compress- Compressvalueobject in cache.
-
GSMapImpl
GSMap constructor.- Parameters:
space- Space proxy or DCache proxy.txn- if notnullall operation will be executed with the desired transaction. To set new transaction use: setTransaction(txn) To reset the transaction use: setTransaction(null) To get the current transaction use: getTransaction()
-
-
Method Details
-
internalPut
protected Object internalPut(Object key, Object value, Transaction txn, long timeToLive, long timeout) throws CacheException Putsvalueto the cache with specifiedkeyandattributesfortimeToLivemilliseconds to live in the cache. If there is novaluewith specifiedkeyin the cache thenvaluewill be written to the cache first time otherwisevaluewill be updated.- Specified by:
internalPutin classAbstractMap- Parameters:
key- key for thevaluevalue- object(~ entry)timeToLive- time to keep object in this cache, in millisecondstimeout- attributes to associate thekeywithtxn- transaction- Returns:
- previous value associated with specified key.
- Throws:
CacheException- if error accord during put
-
internalRemove
protected Object internalRemove(Object key, Transaction txn, long waitForResponse) throws CacheException Removes the mapping for this key from this map if it is present.- Specified by:
internalRemovein classAbstractMap- Parameters:
key- key whose mapping is to be removed from the map.waitForResponse- to wait for response- Returns:
- previous value associated with specified key, or null if there was no mapping for key.
- Throws:
CacheException
-
containsKey
Returns true if the cache contains the specified key. The search is scoped to the cache. Other caches in the system will not be searched and a CacheLoader will not be called.- Parameters:
key- key whose presence in this cache is to be tested.- Returns:
true, if the cache contains the specified key.
-
containsValue
Returns true if this cache maps one or more keys to the specified value. The search is scoped to the cache. Other caches in the system will not be searched and a CacheLoader will not be called.- Parameters:
value- value whose presence in this cache is to be tested.- Returns:
true, if the cache contains the specified value.
-
internalGet
Gets the mapping for this key from this map if it is present.- Specified by:
internalGetin classAbstractMap- Parameters:
key- key whose mapping is to be removed from the map.waitForResponse- to wait for response- Returns:
- previous value associated with specified key.
-
internalGet
protected Object internalGet(Object key, Transaction txn, long waitForResponse, int readModifiers, boolean isRemove) Gets or Removes the mapping for this key from this map if present (optional operation). Client will wait at mostwaitForResponsemilliseconds for get call to return.- Parameters:
isRemove-trueif remove operation, otherwise false;- Returns:
- the value
-
clear
public void clear()The clear method will remove all objects from the cache including the key and the associated value. -
clear
public 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()
-
values
Returns a collection view of the values contained in this cache. The search is scoped to the cache. Other caches in the system will not be searched and a CacheLoader will not be called.- Returns:
- a collection view of the values contained in this cache.
-
entrySet
Returns a set view of the objects currently contained in the cache. The search is scoped to the cache. Other caches in the system will not be searched and a CacheLoader will not be called.- Returns:
- a set of CacheEntry
-
keySet
Returns a set view of the keys currently contained in the cache. The search is scoped to the cache. Other caches in the system will not be searched and a CacheLoader will not be called.- Returns:
- set of the keys
-
addListener
Unsupported Operation! Add a listener to the list of cache listeners.
Optional, not supported by all the implementations, currently supported only by local cache.- Parameters:
listener- call backCacheListener
-
evict
The evict method will remove object from the cache the matches the provided key.- Parameters:
key- the key to evict- Returns:
true, if the key was evicted
-
getCacheEntry
Returns the CacheEntry object associated with the object identified by "key".- Parameters:
key- key whose associated value is to be returned.- Returns:
- the CacheEntry to which this cache maps the specified key, or null if the cache contains no mapping for this key.
-
peek
The peek method will return the object associated with "key" if it currently exists (and is valid) in the cache. The search is scoped to the cache. Other caches in the system will not be searched and a CacheLoader will not be called.- Parameters:
key- key whose associated value is to be peek.- Returns:
- the value to which this cache maps the specified key, or null if the cache contains no mapping for this key.
-
removeListener
Unsupported Operation! Remove a listener from the list of cache listeners.
Optional, not supported by all the implementations, currently supported only by local cache- Parameters:
listener- theCacheListenerto remove
-