GigaSpaces XAP 7.0 API

com.j_spaces.map
Interface IMap

All Superinterfaces:
Cache, Map

public interface IMap
extends Cache

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:
GigaMap

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.
 Object get(Object key, net.jini.core.transaction.Transaction txn, long waitForResponse, int readModifiers)
          Returns the object that is associated with key in this cache.
 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.
 net.jini.core.transaction.Transaction getTransaction()
          Deprecated. use explicit transaction instead
 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, long timeToLive)
          Puts value to the cache with specified key for timeToLive milliseconds to live in the cache.
 Object put(Object key, Object value, long timeToLive, long timeout)
          Puts value to the cache with specified key for timeToLive milliseconds to live in the cache.
 Object put(Object key, Object value, net.jini.core.transaction.Transaction txn, long timeToLive)
          Puts value to the cache with specified key for timeToLive milliseconds to live in the cache.
 Object put(Object key, Object value, net.jini.core.transaction.Transaction txn, long timeToLive, long timeout)
          Puts value to the cache with specified key for timeToLive milliseconds to live in the cache.
 void putAll(Map map, net.jini.core.transaction.Transaction txn, long timeToLive)
          Copies all of the mappings from the specified map to the cache.
 Object remove(Object key, long waitForResponse)
          Removes the mapping for this key from this cache.
 Object remove(Object key, net.jini.core.transaction.Transaction txn, 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(net.jini.core.transaction.Transaction transaction)
          Deprecated. use explicit transaction instead
 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

Object put(Object key,
           Object value,
           long timeToLive,
           long timeout)
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

Object put(Object key,
           Object value,
           net.jini.core.transaction.Transaction txn,
           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)
txn - the transaction object, if any, under which to perform the put
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.
Since:
6.0

put

Object put(Object key,
           Object value,
           net.jini.core.transaction.Transaction txn,
           long timeToLive,
           long timeout)
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)
txn - the transaction object, if any, under which to perform the put
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.
Since:
6.0

putAll

void putAll(Map map,
            net.jini.core.transaction.Transaction txn,
            long timeToLive)
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 cache
txn - the transaction object, if any, under which to perform the put
timeToLive - time to keep object in this cache, in milliseconds
Since:
6.0

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

get

Object get(Object key,
           net.jini.core.transaction.Transaction txn,
           long waitForResponse,
           int readModifiers)
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.
txn - the transaction object, if any, under which to perform the get
waitForResponse - time to wait for response
readModifiers - one or a union of ReadModifiers.
Returns:
Returns the object that is associated with the key
Since:
6.0

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

remove

Object remove(Object key,
              net.jini.core.transaction.Transaction txn,
              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.
txn - the transaction object, if any, under which to perform the remove
waitForResponse - 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 - if true clear also master, when false equals to clear()

setTransaction

@Deprecated
void setTransaction(net.jini.core.transaction.Transaction transaction)
Deprecated. use explicit transaction instead

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

@Deprecated
net.jini.core.transaction.Transaction getTransaction()
Deprecated. use explicit transaction instead

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

GigaSpaces XAP 7.0 API

Copyright © GigaSpaces.