[infinispan-commits] Infinispan SVN: r237 - trunk/core/src/main/java/org/infinispan.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Fri May 8 10:12:38 EDT 2009
Author: manik.surtani at jboss.com
Date: 2009-05-08 10:12:38 -0400 (Fri, 08 May 2009)
New Revision: 237
Modified:
trunk/core/src/main/java/org/infinispan/AbstractDelegatingAdvancedCache.java
trunk/core/src/main/java/org/infinispan/AdvancedCache.java
trunk/core/src/main/java/org/infinispan/Cache.java
trunk/core/src/main/java/org/infinispan/CacheDelegate.java
Log:
[ISPN-72] (AsyncCache) New API methods + javadocs
Modified: trunk/core/src/main/java/org/infinispan/AbstractDelegatingAdvancedCache.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/AbstractDelegatingAdvancedCache.java 2009-05-08 13:54:59 UTC (rev 236)
+++ trunk/core/src/main/java/org/infinispan/AbstractDelegatingAdvancedCache.java 2009-05-08 14:12:38 UTC (rev 237)
@@ -11,6 +11,7 @@
import java.util.List;
import java.util.Map;
+import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
/**
@@ -108,14 +109,74 @@
return cache.remove(key, flags);
}
- public boolean remove(Object key, Object oldValue, Flag... flags) {
- return cache.remove(key, oldValue, flags);
- }
-
public void clear(Flag... flags) {
cache.clear(flags);
}
+ public V replace(K k, V v, Flag... flags) {
+ return cache.replace(k, v, flags);
+ }
+
+ public V replace(K k, V oV, V nV, Flag... flags) {
+ return cache.replace(k, oV, nV, flags);
+ }
+
+ public boolean replace(K k, V v, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit, Flag... flags) {
+ return cache.replace(k, v, lifespan, lifespanUnit, maxIdle, maxIdleUnit, flags);
+ }
+
+ public boolean replace(K k, V oV, V nV, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit, Flag... flags) {
+ return cache.replace(k, oV, nV, lifespan, lifespanUnit, maxIdle, maxIdleUnit, flags);
+ }
+
+ public Future<V> putAsync(K key, V value, Flag... flags) {
+ return cache.putAsync(key, value, flags);
+ }
+
+ public Future<V> putAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit, Flag... flags) {
+ return cache.putAsync(key, value, lifespan, lifespanUnit, maxIdleTime, maxIdleTimeUnit, flags);
+ }
+
+ public Future<V> putIfAbsentAsync(K key, V value, Flag... flags) {
+ return cache.putIfAbsentAsync(key, value, flags);
+ }
+
+ public Future<V> putIfAbsentAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit, Flag... flags) {
+ return cache.putIfAbsentAsync(key, value, lifespan, lifespanUnit, maxIdleTime, maxIdleTimeUnit, flags);
+ }
+
+ public Future<Void> putAllAsync(Map<? extends K, ? extends V> map, Flag... flags) {
+ return cache.putAllAsync(map, flags);
+ }
+
+ public Future<Void> putAllAsync(Map<? extends K, ? extends V> map, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit, Flag... flags) {
+ return cache.putAllAsync(map, lifespan, lifespanUnit, maxIdleTime, maxIdleTimeUnit, flags);
+ }
+
+ public Future<V> removeAsync(Object key, Flag... flags) {
+ return cache.removeAsync(key, flags);
+ }
+
+ public Future<Void> clearAsync(Flag... flags) {
+ return cache.clearAsync(flags);
+ }
+
+ public Future<V> replaceAsync(K k, V v, Flag... flags) {
+ return cache.replaceAsync(k, v, flags);
+ }
+
+ public Future<V> replaceAsync(K k, V oV, V nV, Flag... flags) {
+ return cache.replaceAsync(k, oV, nV, flags);
+ }
+
+ public Future<Boolean> replaceAsync(K k, V v, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit, Flag... flags) {
+ return cache.replaceAsync(k, v, lifespan, lifespanUnit, maxIdle, maxIdleUnit, flags);
+ }
+
+ public Future<Boolean> replaceAsync(K k, V oV, V nV, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit, Flag... flags) {
+ return cache.replaceAsync(k, oV, nV, lifespan, lifespanUnit, maxIdle, maxIdleUnit, flags);
+ }
+
public boolean containsKey(Object key, Flag... flags) {
return cache.containsKey(key, flags);
}
@@ -123,4 +184,76 @@
public V get(Object key, Flag... flags) {
return cache.get(key, flags);
}
+
+ public Future<V> putAsync(K key, V value) {
+ return cache.putAsync(key, value);
+ }
+
+ public Future<V> putAsync(K key, V value, long lifespan, TimeUnit unit) {
+ return cache.putAsync(key, value, lifespan, unit);
+ }
+
+ public Future<V> putAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) {
+ return cache.putAsync(key, value, lifespan, lifespanUnit, maxIdle, maxIdleUnit);
+ }
+
+ public Future<Void> putAllAsync(Map<? extends K, ? extends V> data) {
+ return cache.putAllAsync(data);
+ }
+
+ public Future<Void> putAllAsync(Map<? extends K, ? extends V> data, long lifespan, TimeUnit unit) {
+ return cache.putAllAsync(data, lifespan, unit);
+ }
+
+ public Future<Void> putAllAsync(Map<? extends K, ? extends V> data, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) {
+ return cache.putAllAsync(data, lifespan, lifespanUnit, maxIdle, maxIdleUnit);
+ }
+
+ public Future<Void> clearAsync() {
+ return cache.clearAsync();
+ }
+
+ public Future<V> putIfAbsentAsync(K key, V value) {
+ return cache.putIfAbsentAsync(key, value);
+ }
+
+ public Future<V> putIfAbsentAsync(K key, V value, long lifespan, TimeUnit unit) {
+ return cache.putIfAbsentAsync(key, value, lifespan, unit);
+ }
+
+ public Future<V> putIfAbsentAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) {
+ return cache.putIfAbsentAsync(key, value, lifespan, lifespanUnit, maxIdle, maxIdleUnit);
+ }
+
+ public Future<V> removeAsync(Object key) {
+ return cache.removeAsync(key);
+ }
+
+ public Future<Boolean> removeAsync(Object key, Object value) {
+ return cache.removeAsync(key, value);
+ }
+
+ public Future<V> replaceAsync(K key, V value) {
+ return cache.replaceAsync(key, value);
+ }
+
+ public Future<V> replaceAsync(K key, V value, long lifespan, TimeUnit unit) {
+ return cache.replaceAsync(key, value, lifespan, unit);
+ }
+
+ public Future<V> replaceAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) {
+ return cache.replaceAsync(key, value, lifespan, lifespanUnit, maxIdle, maxIdleUnit);
+ }
+
+ public Future<Boolean> replaceAsync(K key, V oldValue, V newValue) {
+ return cache.replaceAsync(key, oldValue, newValue);
+ }
+
+ public Future<Boolean> replaceAsync(K key, V oldValue, V newValue, long lifespan, TimeUnit unit) {
+ return cache.replaceAsync(key, oldValue, newValue, lifespan, unit);
+ }
+
+ public Future<Boolean> replaceAsync(K key, V oldValue, V newValue, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) {
+ return cache.replaceAsync(key, oldValue, newValue, lifespan, lifespanUnit, maxIdle, maxIdleUnit);
+ }
}
Modified: trunk/core/src/main/java/org/infinispan/AdvancedCache.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/AdvancedCache.java 2009-05-08 13:54:59 UTC (rev 236)
+++ trunk/core/src/main/java/org/infinispan/AdvancedCache.java 2009-05-08 14:12:38 UTC (rev 237)
@@ -11,6 +11,7 @@
import java.util.List;
import java.util.Map;
+import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
/**
@@ -106,6 +107,40 @@
void clear(Flag... flags);
+ V replace(K k, V v, Flag... flags);
+
+ V replace(K k, V oV, V nV, Flag... flags);
+
+ boolean replace(K k, V v, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit, Flag... flags);
+
+ boolean replace(K k, V oV, V nV, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit, Flag... flags);
+
+
+ // -- async methods --
+ Future<V> putAsync(K key, V value, Flag... flags);
+
+ Future<V> putAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit, Flag... flags);
+
+ Future<V> putIfAbsentAsync(K key, V value, Flag... flags);
+
+ Future<V> putIfAbsentAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit, Flag... flags);
+
+ Future<Void> putAllAsync(Map<? extends K, ? extends V> map, Flag... flags);
+
+ Future<Void> putAllAsync(Map<? extends K, ? extends V> map, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit, Flag... flags);
+
+ Future<V> removeAsync(Object key, Flag... flags);
+
+ Future<Void> clearAsync(Flag... flags);
+
+ Future<V> replaceAsync(K k, V v, Flag... flags);
+
+ Future<V> replaceAsync(K k, V oV, V nV, Flag... flags);
+
+ Future<Boolean> replaceAsync(K k, V v, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit, Flag... flags);
+
+ Future<Boolean> replaceAsync(K k, V oV, V nV, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit, Flag... flags);
+
boolean containsKey(Object key, Flag... flags);
V get(Object key, Flag... flags);
Modified: trunk/core/src/main/java/org/infinispan/Cache.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/Cache.java 2009-05-08 13:54:59 UTC (rev 236)
+++ trunk/core/src/main/java/org/infinispan/Cache.java 2009-05-08 14:12:38 UTC (rev 237)
@@ -24,11 +24,14 @@
import org.infinispan.config.Configuration;
import org.infinispan.lifecycle.ComponentStatus;
import org.infinispan.lifecycle.Lifecycle;
+import org.infinispan.loaders.CacheStore;
import org.infinispan.manager.CacheManager;
+import org.infinispan.manager.DefaultCacheManager;
import org.infinispan.notifications.Listenable;
import java.util.Map;
import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
/**
@@ -36,22 +39,41 @@
* with additional features such as:
* <p/>
* <ul> <li>JTA transaction compatibility</li> <li>Eviction support for evicting entries from memory to prevent {@link
- * OutOfMemoryError}s</li> <li>Persisting entries to a {@link org.infinispan.loaders.CacheStore}, either when they are
- * evicted as an overflow, or all the time, to maintain persistent copies that would withstand server failure or
- * restarts.</li> </ul>
+ * OutOfMemoryError}s</li> <li>Persisting entries to a {@link CacheStore}, either when they are evicted as an overflow,
+ * or all the time, to maintain persistent copies that would withstand server failure or restarts.</li> </ul>
* <p/>
* <p/>
* <p/>
- * For convenience, Cache extends {@link java.util.concurrent.ConcurrentMap} and implements all methods accordingly,
- * although methods like {@link java.util.concurrent.ConcurrentMap#keySet()}, {@link
- * java.util.concurrent.ConcurrentMap#values()} and {@link java.util.concurrent.ConcurrentMap#entrySet()} are expensive
+ * For convenience, Cache extends {@link ConcurrentMap} and implements all methods accordingly, although methods like
+ * {@link ConcurrentMap#keySet()}, {@link ConcurrentMap#values()} and {@link ConcurrentMap#entrySet()} are expensive
* (prohibitively so when using a distributed cache) and frequent use of these methods is not recommended.
* <p/>
- * Also, like most {@link java.util.concurrent.ConcurrentMap} implementations, Cache does not support the use of
- * <tt>null</tt> keys (although <tt>null</tt> values are allowed).
+ * Also, like many {@link ConcurrentMap} implementations, Cache does not support the use of <tt>null</tt> keys (although
+ * <tt>null</tt> values are allowed).
* <p/>
- * An instance of the Cache is usually obtained by using a {@link CacheManager}.
+ * <h3>Asynchronous operations</h3> Cache also supports the use of "async" remote operations. Note that these methods
+ * only really make sense if you are using a clustered cache. I.e., when used in LOCAL mode, these "async" operations
+ * offer no benefit whatsoever. These methods, such as {@link #putAsync(Object, Object)} offer the best of both worlds
+ * between a fully synchronous and a fully asynchronous cache in that a {@link Future} is returned. The <tt>Future</tt>
+ * can then be ignored or thrown away for typical asynchronous behaviour, or queried for synchronous behaviour, which
+ * would block until any remote calls complete. Note that all remote calls are, as far as the transport is concerned,
+ * synchronous. This allows you the guarantees that remote calls succeed, while not blocking your application thread
+ * unnecessarily. For example, usage such as the following could benefit from the async operations:
* <pre>
+ * Future f1 = cache.putAsync("key1", "value1");
+ * Future f2 = cache.putAsync("key2", "value2");
+ * Future f3 = cache.putAsync("key3", "value3");
+ * f1.get();
+ * f2.get();
+ * f3.get();
+ * </pre>
+ * The net result is behavior similar to synchronous RPC calls in that at the end, you have guarantees that all calls
+ * completed successfully, but you have the added benefit that the three calls could happen in parallel. This is
+ * especially advantageous if the cache uses distribution and the three keys map to different cache instances in the
+ * cluster.
+ * <p/>
+ * <h3>Constructing a Cache</h3> An instance of the Cache is usually obtained by using a {@link CacheManager}.
+ * <pre>
* CacheManager cm = new DefaultCacheManager(); // optionally pass in a default configuration
* Cache c = cm.getCache();
* </pre>
@@ -65,7 +87,7 @@
* @author Mircea.Markus at jboss.com
* @author Manik Surtani
* @see CacheManager
- * @see org.infinispan.manager.DefaultCacheManager
+ * @see DefaultCacheManager
* @see <a href="http://www.jboss.org/infinispan/docs">Infinispan documentation</a>
* @see <a href="http://www.jboss.org/community/wiki/5minutetutorialonInfinispan">5 Minute Usage Tutorial</a>
* @since 4.0
@@ -73,15 +95,15 @@
public interface Cache<K, V> extends ConcurrentMap<K, V>, Lifecycle, Listenable {
/**
* Under special operating behavior, associates the value with the specified key. <ul> <li> Only goes through if the
- * key specified does not exist; no-op otherwise (similar to {@link java.util.concurrent.ConcurrentMap#putIfAbsent(Object,
- * Object)})</i> <li> Force asynchronous mode for replication to prevent any blocking.</li> <li> invalidation does
- * not take place. </li> <li> 0ms lock timeout to prevent any blocking here either. If the lock is not acquired, this
- * method is a no-op, and swallows the timeout exception.</li> <li> Ongoing transactions are suspended before this
- * call, so failures here will not affect any ongoing transactions.</li> <li> Errors and exceptions are 'silent' -
- * logged at a much lower level than normal, and this method does not throw exceptions</li> </ul> This method is for
- * caching data that has an external representation in storage, where, concurrent modification and transactions are
- * not a consideration, and failure to put the data in the cache should be treated as a 'suboptimal outcome' rather
- * than a 'failing outcome'.
+ * key specified does not exist; no-op otherwise (similar to {@link ConcurrentMap#putIfAbsent(Object, Object)})</i>
+ * <li> Force asynchronous mode for replication to prevent any blocking.</li> <li> invalidation does not take place.
+ * </li> <li> 0ms lock timeout to prevent any blocking here either. If the lock is not acquired, this method is a
+ * no-op, and swallows the timeout exception.</li> <li> Ongoing transactions are suspended before this call, so
+ * failures here will not affect any ongoing transactions.</li> <li> Errors and exceptions are 'silent' - logged at a
+ * much lower level than normal, and this method does not throw exceptions</li> </ul> This method is for caching data
+ * that has an external representation in storage, where, concurrent modification and transactions are not a
+ * consideration, and failure to put the data in the cache should be treated as a 'suboptimal outcome' rather than a
+ * 'failing outcome'.
* <p/>
* An example of when this method is useful is when data is read from, for example, a legacy datastore, and is cached
* before returning the data to the caller. Subsequent calls would prefer to get the data from the cache and if the
@@ -92,23 +114,56 @@
*
* @param key key with which the specified value is to be associated.
* @param value value to be associated with the specified key.
- * @throws IllegalStateException if {@link #getStatus()} would not return {@link org.infinispan.lifecycle.ComponentStatus#RUNNING}.
+ * @throws IllegalStateException if {@link #getStatus()} would not return {@link ComponentStatus#RUNNING}.
*/
void putForExternalRead(K key, V value);
+ /**
+ * Evicts an entry from the memory of the cache. Note that the entry is <i>not</i> removed from any configured cache
+ * stores or any other caches in the cluster (if used in a clustered mode). Use {@link #remove(Object)} to remove an
+ * entry from the entire cache system.
+ * <p/>
+ * This method is designed to evict an entry from memory to free up memory used by the application. This method uses
+ * a 0 lock acquisition timeout so it does not block in attempting to acquire locks. It behaves as a no-op if the
+ * lock on the entry cannot be acquired <i>immediately</i>.
+ * <p/>
+ *
+ * @param key key to evict
+ */
void evict(K key);
Configuration getConfiguration();
/**
+ * Starts a batch. All operations on the current client thread are performed as a part of this batch, with locks
+ * held for the duration of the batch and any remote calls delayed till the end of the batch.
+ * <p/>
+ *
* @return true if a batch was successfully started; false if one was available and already running.
*/
public boolean startBatch();
+ /**
+ * Completes a batch if one has been started using {@link #startBatch()}. If no batch has been started, this is a
+ * no-op.
+ * <p/>
+ *
+ * @param successful if true, the batch completes, otherwise the batch is aborted and changes are not committed.
+ */
public void endBatch(boolean successful);
+ /**
+ * Retrieves the name of the cache
+ *
+ * @return the name of the cache
+ */
String getName();
+ /**
+ * Retrieves the version of Infinispan
+ *
+ * @return a version string
+ */
String getVersion();
/**
@@ -141,8 +196,8 @@
V putIfAbsent(K key, V value, long lifespan, TimeUnit unit);
/**
- * An overloaded form of {@link #putAll(java.util.Map)}, which takes in lifespan parameters. Note that the lifespan
- * is applied to all mappings in the map passed in.
+ * An overloaded form of {@link #putAll(Map)}, which takes in lifespan parameters. Note that the lifespan is applied
+ * to all mappings in the map passed in.
*
* @param map map containing mappings to enter
* @param lifespan lifespan of the entry. Negative values are intepreted as unlimited lifespan.
@@ -202,8 +257,8 @@
V putIfAbsent(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit);
/**
- * An overloaded form of {@link #putAll(java.util.Map)}, which takes in lifespan parameters. Note that the lifespan
- * is applied to all mappings in the map passed in.
+ * An overloaded form of {@link #putAll(Map)}, which takes in lifespan parameters. Note that the lifespan is applied
+ * to all mappings in the map passed in.
*
* @param map map containing mappings to enter
* @param lifespan lifespan of the entry. Negative values are intepreted as unlimited lifespan.
@@ -243,7 +298,231 @@
*/
boolean replace(K key, V oldValue, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit);
+ /**
+ * Asynchronous version of {@link #put(Object, Object)}. This method does not block on remote calls, even if your
+ * cache mode is synchronous. Has no benefit over {@link #put(Object, Object)} if used in LOCAL mode.
+ * <p/>
+ *
+ * @param key key to use
+ * @param value value to store
+ * @return a future containing the old value replaced.
+ */
+ Future<V> putAsync(K key, V value);
+ /**
+ * Asynchronous version of {@link #put(Object, Object, long, TimeUnit)} . This method does not block on remote
+ * calls, even if your cache mode is synchronous. Has no benefit over {@link #put(Object, Object, long, TimeUnit)}
+ * if used in LOCAL mode.
+ *
+ * @param key key to use
+ * @param value value to store
+ * @param lifespan lifespan of entry
+ * @param unit time unit for lifespan
+ * @return a future containing the old value replaced
+ */
+ Future<V> putAsync(K key, V value, long lifespan, TimeUnit unit);
+
+ /**
+ * Asynchronous version of {@link #put(Object, Object, long, TimeUnit, long, TimeUnit)}. This method does not block
+ * on remote calls, even if your cache mode is synchronous. Has no benefit over {@link #put(Object, Object, long,
+ * TimeUnit, long, TimeUnit)} if used in LOCAL mode.
+ *
+ * @param key key to use
+ * @param value value to store
+ * @param lifespan lifespan of entry
+ * @param lifespanUnit time unit for lifespan
+ * @param maxIdle the maximum amount of time this key is allowed to be idle for before it is considered as
+ * expired
+ * @param maxIdleUnit time unit for max idle time
+ * @return a future containing the old value replaced
+ */
+ Future<V> putAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit);
+
+ /**
+ * Asynchronous version of {@link #putAll(Map)}. This method does not block on remote calls, even if your cache mode
+ * is synchronous. Has no benefit over {@link #putAll(Map)} if used in LOCAL mode.
+ *
+ * @param data to store
+ * @return a future containing a void return type
+ */
+ Future<Void> putAllAsync(Map<? extends K, ? extends V> data);
+
+ /**
+ * Asynchronous version of {@link #putAll(Map, long, TimeUnit)}. This method does not block on remote calls, even if
+ * your cache mode is synchronous. Has no benefit over {@link #putAll(Map, long, TimeUnit)} if used in LOCAL mode.
+ *
+ * @param data to store
+ * @param lifespan lifespan of entry
+ * @param unit time unit for lifespan
+ * @return a future containing a void return type
+ */
+ Future<Void> putAllAsync(Map<? extends K, ? extends V> data, long lifespan, TimeUnit unit);
+
+ /**
+ * Asynchronous version of {@link #putAll(Map, long, TimeUnit, long, TimeUnit)}. This method does not block on
+ * remote calls, even if your cache mode is synchronous. Has no benefit over {@link #putAll(Map, long, TimeUnit,
+ * long, TimeUnit)} if used in LOCAL mode.
+ *
+ * @param data to store
+ * @param lifespan lifespan of entry
+ * @param lifespanUnit time unit for lifespan
+ * @param maxIdle the maximum amount of time this key is allowed to be idle for before it is considered as
+ * expired
+ * @param maxIdleUnit time unit for max idle time
+ * @return a future containing a void return type
+ */
+ Future<Void> putAllAsync(Map<? extends K, ? extends V> data, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit);
+
+ /**
+ * Asynchronous version of {@link #clear()}. This method does not block on remote calls, even if your cache mode is
+ * synchronous. Has no benefit over {@link #clear()} if used in LOCAL mode.
+ *
+ * @return a future containing a void return type
+ */
+ Future<Void> clearAsync();
+
+ /**
+ * Asynchronous version of {@link #putIfAbsent(Object, Object)}. This method does not block on remote calls, even if
+ * your cache mode is synchronous. Has no benefit over {@link #putIfAbsent(Object, Object)} if used in LOCAL mode.
+ * <p/>
+ *
+ * @param key key to use
+ * @param value value to store
+ * @return a future containing the old value replaced.
+ */
+ Future<V> putIfAbsentAsync(K key, V value);
+
+ /**
+ * Asynchronous version of {@link #putIfAbsent(Object, Object, long, TimeUnit)} . This method does not block on
+ * remote calls, even if your cache mode is synchronous. Has no benefit over {@link #putIfAbsent(Object, Object,
+ * long, TimeUnit)} if used in LOCAL mode.
+ *
+ * @param key key to use
+ * @param value value to store
+ * @param lifespan lifespan of entry
+ * @param unit time unit for lifespan
+ * @return a future containing the old value replaced
+ */
+ Future<V> putIfAbsentAsync(K key, V value, long lifespan, TimeUnit unit);
+
+ /**
+ * Asynchronous version of {@link #putIfAbsent(Object, Object, long, TimeUnit, long, TimeUnit)}. This method does
+ * not block on remote calls, even if your cache mode is synchronous. Has no benefit over {@link
+ * #putIfAbsent(Object, Object, long, TimeUnit, long, TimeUnit)} if used in LOCAL mode.
+ *
+ * @param key key to use
+ * @param value value to store
+ * @param lifespan lifespan of entry
+ * @param lifespanUnit time unit for lifespan
+ * @param maxIdle the maximum amount of time this key is allowed to be idle for before it is considered as
+ * expired
+ * @param maxIdleUnit time unit for max idle time
+ * @return a future containing the old value replaced
+ */
+ Future<V> putIfAbsentAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit);
+
+ /**
+ * Asynchronous version of {@link #remove(Object)}. This method does not block on remote calls, even if your cache
+ * mode is synchronous. Has no benefit over {@link #remove(Object)} if used in LOCAL mode.
+ *
+ * @param key key to remove
+ * @return a future containing the value removed
+ */
+ Future<V> removeAsync(Object key);
+
+ /**
+ * Asynchronous version of {@link #remove(Object, Object)}. This method does not block on remote calls, even if your
+ * cache mode is synchronous. Has no benefit over {@link #remove(Object, Object)} if used in LOCAL mode.
+ *
+ * @param key key to remove
+ * @param value value to match on
+ * @return a future containing a boolean, indicating whether the entry was removed or not
+ */
+ Future<Boolean> removeAsync(Object key, Object value);
+
+ /**
+ * Asynchronous version of {@link #replace(Object, Object)}. This method does not block on remote calls, even if
+ * your cache mode is synchronous. Has no benefit over {@link #replace(Object, Object)} if used in LOCAL mode.
+ *
+ * @param key key to remove
+ * @param value value to store
+ * @return a future containing the previous value overwritten
+ */
+ Future<V> replaceAsync(K key, V value);
+
+ /**
+ * Asynchronous version of {@link #replace(Object, Object, long, TimeUnit)}. This method does not block on remote
+ * calls, even if your cache mode is synchronous. Has no benefit over {@link #replace(Object, Object, long,
+ * TimeUnit)} if used in LOCAL mode.
+ *
+ * @param key key to remove
+ * @param value value to store
+ * @param lifespan lifespan of entry
+ * @param unit time unit for lifespan
+ * @return a future containing the previous value overwritten
+ */
+ Future<V> replaceAsync(K key, V value, long lifespan, TimeUnit unit);
+
+ /**
+ * Asynchronous version of {@link #replace(Object, Object, long, TimeUnit, long, TimeUnit)}. This method does not
+ * block on remote calls, even if your cache mode is synchronous. Has no benefit over {@link #replace(Object,
+ * Object, long, TimeUnit, long, TimeUnit)} if used in LOCAL mode.
+ *
+ * @param key key to remove
+ * @param value value to store
+ * @param lifespan lifespan of entry
+ * @param lifespanUnit time unit for lifespan
+ * @param maxIdle the maximum amount of time this key is allowed to be idle for before it is considered as
+ * expired
+ * @param maxIdleUnit time unit for max idle time
+ * @return a future containing the previous value overwritten
+ */
+ Future<V> replaceAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit);
+
+ /**
+ * Asynchronous version of {@link #replace(Object, Object, Object)}. This method does not block on remote calls,
+ * even if your cache mode is synchronous. Has no benefit over {@link #replace(Object, Object, Object)} if used in
+ * LOCAL mode.
+ *
+ * @param key key to remove
+ * @param oldValue value to overwrite
+ * @param newValue value to store
+ * @return a future containing a boolean, indicating whether the entry was replaced or not
+ */
+ Future<Boolean> replaceAsync(K key, V oldValue, V newValue);
+
+ /**
+ * Asynchronous version of {@link #replace(Object, Object, Object, long, TimeUnit)}. This method does not block on
+ * remote calls, even if your cache mode is synchronous. Has no benefit over {@link #replace(Object, Object, Object,
+ * long, TimeUnit)} if used in LOCAL mode.
+ *
+ * @param key key to remove
+ * @param oldValue value to overwrite
+ * @param newValue value to store
+ * @param lifespan lifespan of entry
+ * @param unit time unit for lifespan
+ * @return a future containing a boolean, indicating whether the entry was replaced or not
+ */
+ Future<Boolean> replaceAsync(K key, V oldValue, V newValue, long lifespan, TimeUnit unit);
+
+ /**
+ * Asynchronous version of {@link #replace(Object, Object, Object, long, TimeUnit, long, TimeUnit)}. This method
+ * does not block on remote calls, even if your cache mode is synchronous. Has no benefit over {@link
+ * #replace(Object, Object, Object, long, TimeUnit, long, TimeUnit)} if used in LOCAL mode.
+ *
+ * @param key key to remove
+ * @param oldValue value to overwrite
+ * @param newValue value to store
+ * @param lifespan lifespan of entry
+ * @param lifespanUnit time unit for lifespan
+ * @param maxIdle the maximum amount of time this key is allowed to be idle for before it is considered as
+ * expired
+ * @param maxIdleUnit time unit for max idle time
+ * @return a future containing a boolean, indicating whether the entry was replaced or not
+ */
+ Future<Boolean> replaceAsync(K key, V oldValue, V newValue, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit);
+
+
AdvancedCache<K, V> getAdvancedCache();
/**
Modified: trunk/core/src/main/java/org/infinispan/CacheDelegate.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/CacheDelegate.java 2009-05-08 13:54:59 UTC (rev 236)
+++ trunk/core/src/main/java/org/infinispan/CacheDelegate.java 2009-05-08 14:12:38 UTC (rev 237)
@@ -64,6 +64,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
@@ -335,16 +336,75 @@
return remove(key);
}
- public boolean remove(Object key, Object oldValue, Flag... flags) {
- getInvocationContext().setFlags(flags);
- return remove(key, oldValue);
- }
-
public void clear(Flag... flags) {
getInvocationContext().setFlags(flags);
clear();
}
+ public V replace(K k, V v, Flag... flags) {
+ return null; // TODO: Customise this generated block
+ }
+
+ public V replace(K k, V oV, V nV, Flag... flags) {
+ return null; // TODO: Customise this generated block
+ }
+
+ public boolean replace(K k, V v, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit, Flag... flags) {
+ return false; // TODO: Customise this generated block
+ }
+
+ public boolean replace(K k, V oV, V nV, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit, Flag... flags) {
+ return false; // TODO: Customise this generated block
+ }
+
+ public Future<V> putAsync(K key, V value, Flag... flags) {
+ return null; // TODO: Customise this generated block
+ }
+
+ public Future<V> putAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit, Flag... flags) {
+ return null; // TODO: Customise this generated block
+ }
+
+ public Future<V> putIfAbsentAsync(K key, V value, Flag... flags) {
+ return null; // TODO: Customise this generated block
+ }
+
+ public Future<V> putIfAbsentAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit, Flag... flags) {
+ return null; // TODO: Customise this generated block
+ }
+
+ public Future<Void> putAllAsync(Map<? extends K, ? extends V> map, Flag... flags) {
+ return null; // TODO: Customise this generated block
+ }
+
+ public Future<Void> putAllAsync(Map<? extends K, ? extends V> map, long lifespan, TimeUnit lifespanUnit, long maxIdleTime, TimeUnit maxIdleTimeUnit, Flag... flags) {
+ return null; // TODO: Customise this generated block
+ }
+
+ public Future<V> removeAsync(Object key, Flag... flags) {
+ return null; // TODO: Customise this generated block
+ }
+
+ public Future<Void> clearAsync(Flag... flags) {
+ return null; // TODO: Customise this generated block
+ }
+
+ public Future<V> replaceAsync(K k, V v, Flag... flags) {
+ return null; // TODO: Customise this generated block
+ }
+
+ public Future<V> replaceAsync(K k, V oV, V nV, Flag... flags) {
+ return null; // TODO: Customise this generated block
+ }
+
+ public Future<Boolean> replaceAsync(K k, V v, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit, Flag... flags) {
+ return null; // TODO: Customise this generated block
+ }
+
+ public Future<Boolean> replaceAsync(K k, V oV, V nV, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit, Flag... flags) {
+ return null; // TODO: Customise this generated block
+ }
+
public boolean containsKey(Object key, Flag... flags) {
getInvocationContext().setFlags(flags);
return containsKey(key);
@@ -436,6 +496,78 @@
return (Boolean) invoker.invoke(getInvocationContext(), command);
}
+ public Future<V> putAsync(K key, V value) {
+ return null; // TODO: Customise this generated block
+ }
+
+ public Future<V> putAsync(K key, V value, long lifespan, TimeUnit unit) {
+ return null; // TODO: Customise this generated block
+ }
+
+ public Future<V> putAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) {
+ return null; // TODO: Customise this generated block
+ }
+
+ public Future<Void> putAllAsync(Map<? extends K, ? extends V> data) {
+ return null; // TODO: Customise this generated block
+ }
+
+ public Future<Void> putAllAsync(Map<? extends K, ? extends V> data, long lifespan, TimeUnit unit) {
+ return null; // TODO: Customise this generated block
+ }
+
+ public Future<Void> putAllAsync(Map<? extends K, ? extends V> data, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) {
+ return null; // TODO: Customise this generated block
+ }
+
+ public Future<Void> clearAsync() {
+ return null; // TODO: Customise this generated block
+ }
+
+ public Future<V> putIfAbsentAsync(K key, V value) {
+ return null; // TODO: Customise this generated block
+ }
+
+ public Future<V> putIfAbsentAsync(K key, V value, long lifespan, TimeUnit unit) {
+ return null; // TODO: Customise this generated block
+ }
+
+ public Future<V> putIfAbsentAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) {
+ return null; // TODO: Customise this generated block
+ }
+
+ public Future<V> removeAsync(Object key) {
+ return null; // TODO: Customise this generated block
+ }
+
+ public Future<Boolean> removeAsync(Object key, Object value) {
+ return null; // TODO: Customise this generated block
+ }
+
+ public Future<V> replaceAsync(K key, V value) {
+ return null; // TODO: Customise this generated block
+ }
+
+ public Future<V> replaceAsync(K key, V value, long lifespan, TimeUnit unit) {
+ return null; // TODO: Customise this generated block
+ }
+
+ public Future<V> replaceAsync(K key, V value, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) {
+ return null; // TODO: Customise this generated block
+ }
+
+ public Future<Boolean> replaceAsync(K key, V oldValue, V newValue) {
+ return null; // TODO: Customise this generated block
+ }
+
+ public Future<Boolean> replaceAsync(K key, V oldValue, V newValue, long lifespan, TimeUnit unit) {
+ return null; // TODO: Customise this generated block
+ }
+
+ public Future<Boolean> replaceAsync(K key, V oldValue, V newValue, long lifespan, TimeUnit lifespanUnit, long maxIdle, TimeUnit maxIdleUnit) {
+ return null; // TODO: Customise this generated block
+ }
+
@SuppressWarnings("unchecked")
public V put(K key, V value, long lifespan, TimeUnit unit) {
return put(key, value, lifespan, unit, defaultMaxIdleTime, MILLISECONDS);
More information about the infinispan-commits
mailing list