com.j_spaces.map
Interface IMap

All Superinterfaces:
Cache, Map
All Known Implementing Classes:
com.j_spaces.map.AbstractMap, GSMapImpl

public interface IMap
extends Cache

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

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Method Summary
 void clear(boolean clearMaster)
          The clear method will remove all objects from the cache including the key and the associated value.
 Object get(Object key, long waitForResponse)
          Returns the object that is associated with key in this cache.
 Attribute getAttribute(Object key, String attributeName)
          Deprecated. This method will not be available in future versions
 Attribute[] getAttributes(Object key)
          Deprecated. This method will not be available in future versions
 Attribute[] getAttributes(Object key, long waitForResponse)
          Deprecated. This method will not be available in future versions
 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 put(java.lang.Object, java.lang.Object, long), get(java.lang.Object, long) and remove(java.lang.Object, long) calls.
 boolean isVersioned()
          Check if using optimistic locking.
 Object put(Object key, Object value, Attribute[] attributes)
          Deprecated. This method will not be available in future versions.
 Object put(Object key, Object value, Attribute[] attributes, long timeToLive)
          Deprecated. This method will not be available in future versions.
 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 remove(Object key, 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 put(java.lang.Object, java.lang.Object, long), get(java.lang.Object, long) and remove(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, values
 

Method Detail

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 the put(java.lang.Object, java.lang.Object, long), get(java.lang.Object, long) and remove(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 the put(java.lang.Object, java.lang.Object, long), get(java.lang.Object, long) and remove(java.lang.Object, long) calls.

Returns:
time to wait for response

put

Object put(Object key,
           Object value,
           long timeToLive)
Puts value to the cache with specified key for timeToLive milliseconds to live in the cache.

Parameters:
key - key for the value
value - 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

@Deprecated
Object put(Object key,
                      Object value,
                      Attribute[] attributes)
Deprecated. This method will not be available in future versions.

Puts value to the cache with specified key and attributes.

Parameters:
key - key for the value
value - object(~ entry)
attributes - attributes to associate the value with
Returns:
previous value associated with specified key, or null if there was no mapping for key.

put

@Deprecated
Object put(Object key,
                      Object value,
                      Attribute[] attributes,
                      long timeToLive)
Deprecated. This method will not be available in future versions.

Puts value to the cache with specified key and attributes for timeToLive milliseconds to live in the cache.

Parameters:
key - key for the value
value - object(~ entry)
timeToLive - time to keep object in this cache, in milliseconds
attributes - attributes to associate the key with
Returns:
previous value associated with specified key, or null if there was no mapping for key.

get

Object get(Object key,
           long waitForResponse)
Returns the object that is associated with key in this cache. Client will wait at most waitForResponse milliseconds 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

remove

Object remove(Object key,
              long waitForResponse)
Removes the mapping for this key from this cache. Client will wait at most waitForResponse milliseconds 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

clear

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()

getAttributes

@Deprecated
Attribute[] getAttributes(Object key)
Deprecated. This method will not be available in future versions

Returns the attributes associated with the key.

Parameters:
key - the key to an object in this cache
Returns:
array of attributes that are associated with the key

getAttributes

@Deprecated
Attribute[] getAttributes(Object key,
                                     long waitForResponse)
Deprecated. This method will not be available in future versions

Returns the attributes associated with the key Client will wait at most waitForResponse milliseconds for get call to return.

Parameters:
key - the key to an object in this cache
waitForResponse - time to wait for response
Returns:
array of attributes that are associated with the key

getAttribute

@Deprecated
Attribute getAttribute(Object key,
                                  String attributeName)
Deprecated. This method will not be available in future versions

Returns the attribute (if any) that is associated with the key and its name equals to attributeName.

Parameters:
key - the key to an object in this cache
attributeName - name of the attribute associated with the key
Returns:
The Attribute object

setTransaction

void setTransaction(Transaction transaction)
Set current transaction, all the map calls will be performed under this transaction. Setting to 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
 

Parameters:
transaction - active transaction or null

getTransaction

Transaction getTransaction()
Returns active transaction or null if 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 - true if optimistic locking is needed

isVersioned

boolean isVersioned()
Check if using optimistic locking.

Returns:
true if using optimistic locking