if ttl = 0 then entry stored infinitely

pull/365/head
Nikita 9 years ago
parent 4c94081724
commit 396fa641f2

@ -194,6 +194,13 @@ public class RedissonMapCache<K, V> extends RedissonMap<K, V> implements RMapCac
@Override
public Future<V> putIfAbsentAsync(K key, V value, long ttl, TimeUnit unit) {
if (ttl < 0) {
throw new IllegalArgumentException("TTL can't be negative");
}
if (ttl == 0) {
return putIfAbsentAsync(key, value);
}
if (unit == null) {
throw new NullPointerException("TimeUnit param can't be null");
}
@ -274,6 +281,13 @@ public class RedissonMapCache<K, V> extends RedissonMap<K, V> implements RMapCac
@Override
public Future<V> putAsync(K key, V value, long ttl, TimeUnit unit) {
if (ttl < 0) {
throw new IllegalArgumentException("TTL can't be negative");
}
if (ttl == 0) {
return putAsync(key, value);
}
if (unit == null) {
throw new NullPointerException("TimeUnit param can't be null");
}

@ -330,6 +330,13 @@ public class RedissonSetCache<V> extends RedissonExpirable implements RSetCache<
@Override
public Future<Boolean> addAsync(V value, long ttl, TimeUnit unit) {
if (ttl < 0) {
throw new IllegalArgumentException("TTL can't be negative");
}
if (ttl == 0) {
return addAsync(value);
}
if (unit == null) {
throw new NullPointerException("TimeUnit param can't be null");
}

@ -38,8 +38,37 @@ import java.util.concurrent.TimeUnit;
*/
public interface RMapCache<K, V> extends RMap<K, V>, RMapCacheAsync<K, V> {
/**
* If the specified key is not already associated
* with a value, associate it with the given value.
* <p/>
* Stores value mapped by key with specified time to live.
* Entry expires after specified time to live.
* If the map previously contained a mapping for
* the key, the old value is replaced by the specified value.
*
* @param key
* @param value
* @param ttl - time to live for key\value entry.
* If <code>0</code> then stores infinitely.
* @param unit
* @return previous associated value
*/
V putIfAbsent(K key, V value, long ttl, TimeUnit unit);
/**
* Stores value mapped by key with specified time to live.
* Entry expires after specified time to live.
* If the map previously contained a mapping for
* the key, the old value is replaced by the specified value.
*
* @param key
* @param value
* @param ttl - time to live for key\value entry.
* If <code>0</code> then stores infinitely.
* @param unit
* @return previous associated value
*/
V put(K key, V value, long ttl, TimeUnit unit);
/**

@ -40,8 +40,37 @@ import io.netty.util.concurrent.Future;
*/
public interface RMapCacheAsync<K, V> extends RMapAsync<K, V> {
/**
* If the specified key is not already associated
* with a value, associate it with the given value.
* <p/>
* Stores value mapped by key with specified time to live.
* Entry expires after specified time to live.
* If the map previously contained a mapping for
* the key, the old value is replaced by the specified value.
*
* @param key
* @param value
* @param ttl - time to live for key\value entry.
* If <code>0</code> then stores infinitely.
* @param unit
* @return previous associated value
*/
Future<V> putIfAbsentAsync(K key, V value, long ttl, TimeUnit unit);
/**
* Stores value mapped by key with specified time to live.
* Entry expires after specified time to live.
* If the map previously contained a mapping for
* the key, the old value is replaced by the specified value.
*
* @param key
* @param value
* @param ttl - time to live for key\value entry.
* If <code>0</code> then stores infinitely.
* @param unit
* @return previous associated value
*/
Future<V> putAsync(K key, V value, long ttl, TimeUnit unit);
/**

@ -41,6 +41,18 @@ import java.util.concurrent.TimeUnit;
*/
public interface RSetCache<V> extends Set<V>, RExpirable, RSetCacheAsync<V> {
/**
* Stores value with specified time to live.
* Value expires after specified time to live.
*
* @param key
* @param value
* @param ttl - time to live for key\value entry.
* If <code>0</code> then stores infinitely.
* @param unit
* @return <code>true</code> if value has been added. <code>false</code>
* if value already been in collection.
*/
boolean add(V value, long ttl, TimeUnit unit);
/**

@ -28,6 +28,18 @@ import io.netty.util.concurrent.Future;
*/
public interface RSetCacheAsync<V> extends RCollectionAsync<V> {
/**
* Stores value with specified time to live.
* Value expires after specified time to live.
*
* @param key
* @param value
* @param ttl - time to live for key\value entry.
* If <code>0</code> then stores infinitely.
* @param unit
* @return <code>true</code> if value has been added. <code>false</code>
* if value already been in collection.
*/
Future<Boolean> addAsync(V value, long ttl, TimeUnit unit);
/**

Loading…
Cancel
Save