DATAREDIS-786 - Polishing.
Update Javadoc and add setIfPresent to BoundValueOperations. Original Pull Request: #334
This commit is contained in:
@@ -25,6 +25,7 @@ import org.springframework.lang.Nullable;
|
||||
* @author Costin Leau
|
||||
* @author Mark Paluch
|
||||
* @author Jiahe Cai
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
public interface BoundValueOperations<K, V> extends BoundKeyOperations<K> {
|
||||
|
||||
@@ -69,6 +70,32 @@ public interface BoundValueOperations<K, V> extends BoundKeyOperations<K> {
|
||||
@Nullable
|
||||
Boolean setIfAbsent(V value, long timeout, TimeUnit unit);
|
||||
|
||||
/**
|
||||
* Set the bound key to hold the string {@code value} if {@code key} is present.
|
||||
*
|
||||
* @param value must not be {@literal null}.
|
||||
* @return command result indicating if the key has been set.
|
||||
* @throws IllegalArgumentException if {@code value} is not present.
|
||||
* @see <a href="http://redis.io/commands/set">Redis Documentation: SET</a>
|
||||
* @since 2.1
|
||||
*/
|
||||
@Nullable
|
||||
Boolean setIfPresent(V value);
|
||||
|
||||
/**
|
||||
* Set the bound key to hold the string {@code value} and expiration {@code timeout} if {@code key} is present.
|
||||
*
|
||||
* @param value must not be {@literal null}.
|
||||
* @param timeout the key expiration timeout.
|
||||
* @param unit must not be {@literal null}.
|
||||
* @return command result indicating if the key has been set.
|
||||
* @throws IllegalArgumentException if either {@code value} or {@code timeout} is not present.
|
||||
* @see <a href="http://redis.io/commands/set">Redis Documentation: SET</a>
|
||||
* @since 2.1
|
||||
*/
|
||||
@Nullable
|
||||
Boolean setIfPresent(V value, long timeout, TimeUnit unit);
|
||||
|
||||
/**
|
||||
* Get the value of the bound key.
|
||||
*
|
||||
@@ -90,7 +117,6 @@ public interface BoundValueOperations<K, V> extends BoundKeyOperations<K> {
|
||||
/**
|
||||
* Increment an integer value stored as string value under the bound key by one.
|
||||
*
|
||||
* @param delta
|
||||
* @return {@literal null} when used in pipeline / transaction.
|
||||
* @since 2.1
|
||||
* @see <a href="http://redis.io/commands/incr">Redis Documentation: INCR</a>
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.data.redis.core;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.springframework.data.redis.connection.DataType;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* @author Costin Leau
|
||||
@@ -157,6 +158,26 @@ class DefaultBoundValueOperations<K, V> extends DefaultBoundKeyOperations<K> imp
|
||||
return ops.setIfAbsent(getKey(), value, timeout, unit);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.core.BoundValueOperations#setIfPresent(java.lang.Object)
|
||||
*/
|
||||
@Nullable
|
||||
@Override
|
||||
public Boolean setIfPresent(V value) {
|
||||
return ops.setIfPresent(getKey(), value);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.core.BoundValueOperations#setIfPresent(java.lang.Object, long, java.util.concurrent.TimeUnit)
|
||||
*/
|
||||
@Nullable
|
||||
@Override
|
||||
public Boolean setIfPresent(V value, long timeout, TimeUnit unit) {
|
||||
return ops.setIfPresent(getKey(), value, timeout, unit);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.core.BoundValueOperations#set(java.lang.Object, long)
|
||||
|
||||
@@ -36,7 +36,7 @@ public interface ValueOperations<K, V> {
|
||||
* Set {@code value} for {@code key}.
|
||||
*
|
||||
* @param key must not be {@literal null}.
|
||||
* @param value
|
||||
* @param value must not be {@literal null}.
|
||||
* @see <a href="http://redis.io/commands/set">Redis Documentation: SET</a>
|
||||
*/
|
||||
void set(K key, V value);
|
||||
@@ -45,8 +45,8 @@ public interface ValueOperations<K, V> {
|
||||
* Set the {@code value} and expiration {@code timeout} for {@code key}.
|
||||
*
|
||||
* @param key must not be {@literal null}.
|
||||
* @param value
|
||||
* @param timeout
|
||||
* @param value must not be {@literal null}.
|
||||
* @param timeout the key expiration timeout.
|
||||
* @param unit must not be {@literal null}.
|
||||
* @see <a href="http://redis.io/commands/setex">Redis Documentation: SETEX</a>
|
||||
*/
|
||||
@@ -56,7 +56,7 @@ public interface ValueOperations<K, V> {
|
||||
* Set {@code key} to hold the string {@code value} if {@code key} is absent.
|
||||
*
|
||||
* @param key must not be {@literal null}.
|
||||
* @param value
|
||||
* @param value must not be {@literal null}.
|
||||
* @return {@literal null} when used in pipeline / transaction.
|
||||
* @see <a href="http://redis.io/commands/setnx">Redis Documentation: SETNX</a>
|
||||
*/
|
||||
@@ -67,8 +67,8 @@ public interface ValueOperations<K, V> {
|
||||
* Set {@code key} to hold the string {@code value} and expiration {@code timeout} if {@code key} is absent.
|
||||
*
|
||||
* @param key must not be {@literal null}.
|
||||
* @param value
|
||||
* @param timeout must not be {@literal null}.
|
||||
* @param value must not be {@literal null}.
|
||||
* @param timeout the key expiration timeout.
|
||||
* @param unit must not be {@literal null}.
|
||||
* @return {@literal null} when used in pipeline / transaction.
|
||||
* @since 2.1
|
||||
@@ -81,9 +81,11 @@ public interface ValueOperations<K, V> {
|
||||
* Set {@code key} to hold the string {@code value} if {@code key} is present.
|
||||
*
|
||||
* @param key must not be {@literal null}.
|
||||
* @param value
|
||||
* @since 2.1
|
||||
* @param value must not be {@literal null}.
|
||||
* @return command result indicating if the key has been set.
|
||||
* @throws IllegalArgumentException if either {@code key} or {@code value} is not present.
|
||||
* @see <a href="http://redis.io/commands/set">Redis Documentation: SET</a>
|
||||
* @since 2.1
|
||||
*/
|
||||
@Nullable
|
||||
Boolean setIfPresent(K key, V value);
|
||||
@@ -92,10 +94,13 @@ public interface ValueOperations<K, V> {
|
||||
* Set {@code key} to hold the string {@code value} and expiration {@code timeout} if {@code key} is present.
|
||||
*
|
||||
* @param key must not be {@literal null}.
|
||||
* @param value
|
||||
* @param timeout must not be {@literal null}.
|
||||
* @since 2.1
|
||||
* @param value must not be {@literal null}.
|
||||
* @param timeout the key expiration timeout.
|
||||
* @param unit must not be {@literal null}.
|
||||
* @return command result indicating if the key has been set.
|
||||
* @throws IllegalArgumentException if either {@code key}, {@code value} or {@code timeout} is not present.
|
||||
* @see <a href="http://redis.io/commands/set">Redis Documentation: SET</a>
|
||||
* @since 2.1
|
||||
*/
|
||||
@Nullable
|
||||
Boolean setIfPresent(K key, V value, long timeout, TimeUnit unit);
|
||||
|
||||
Reference in New Issue
Block a user