Class GSMapImpl

All Implemented Interfaces:
Cache, IMap, Map

public final class GSMapImpl extends AbstractMap
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
  • Constructor Details

    • GSMapImpl

      protected GSMapImpl(IJSpace space, long timeToLive, Transaction txn, int compress)
      GSMapImpl constructor. _serializationType
      Parameters:
      space - Space proxy or DCache proxy.
      timeToLive - Time to live for value object in cache, use -1 for default value.
      txn - if not null all 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

      public GSMapImpl(IJSpace space)
      GSMap constructor.
      Parameters:
      space - Space proxy or DCache proxy.
    • GSMapImpl

      public GSMapImpl(IJSpace space, long timeToLive)
      GSMap constructor.
      Parameters:
      space - Space proxy or DCache proxy.
      timeToLive - Time to live for value object in cache.
    • GSMapImpl

      public GSMapImpl(IJSpace space, int compress)
      GSMap constructor.
      Parameters:
      space - Space proxy or DCache proxy.
      compress - Compress value object in cache.
    • GSMapImpl

      public GSMapImpl(IJSpace space, Transaction txn)
      GSMap constructor.
      Parameters:
      space - Space proxy or DCache proxy.
      txn - if not null all 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
      Puts value to the cache with specified key and attributes for timeToLive milliseconds to live in the cache. If there is no value with specified key in the cache then value will be written to the cache first time otherwise value will be updated.
      Specified by:
      internalPut in class AbstractMap
      Parameters:
      key - key for the value
      value - object(~ entry)
      timeToLive - time to keep object in this cache, in milliseconds
      timeout - attributes to associate the key with
      txn - 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:
      internalRemove in class AbstractMap
      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

      public boolean containsKey(Object key)
      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

      public boolean containsValue(Object value)
      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

      protected Object internalGet(Object key, Transaction txn, long waitForResponse, int readModifiers)
      Gets the mapping for this key from this map if it is present.
      Specified by:
      internalGet in class AbstractMap
      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 most waitForResponse milliseconds for get call to return.
      Parameters:
      isRemove - true if 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 - if true clear also master, when false equals to clear()
    • values

      public Collection 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

      public Set 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

      public Set 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

      public final void addListener(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.
      Parameters:
      listener - call back CacheListener
    • evict

      public final boolean evict(Object key)
      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

      public final CacheEntry getCacheEntry(Object key)
      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

      public Object peek(Object key)
      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

      public void removeListener(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 cache
      Parameters:
      listener - the CacheListener to remove