diff --git a/src/main/java/org/springframework/data/redis/connection/RedisStringCommands.java b/src/main/java/org/springframework/data/redis/connection/RedisStringCommands.java index fa53386c9..b782c7966 100644 --- a/src/main/java/org/springframework/data/redis/connection/RedisStringCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/RedisStringCommands.java @@ -25,6 +25,7 @@ import org.springframework.data.redis.core.types.Expiration; * * @author Costin Leau * @author Christoph Strobl + * @author Mark Paluch */ public interface RedisStringCommands { @@ -37,7 +38,7 @@ public interface RedisStringCommands { *
* See http://redis.io/commands/get * - * @param key + * @param key must not be {@literal null}. * @return */ byte[] get(byte[] key); @@ -47,7 +48,7 @@ public interface RedisStringCommands { *
* See http://redis.io/commands/getset * - * @param key + * @param key must not be {@literal null}. * @param value * @return */ @@ -68,8 +69,8 @@ public interface RedisStringCommands { *
* See http://redis.io/commands/set * - * @param key - * @param value + * @param key must not be {@literal null}. + * @param value must not be {@literal null}. */ void set(byte[] key, byte[] value); @@ -92,8 +93,8 @@ public interface RedisStringCommands { *
* See http://redis.io/commands/setnx * - * @param key - * @param value + * @param key must not be {@literal null}. + * @param value must not be {@literal null}. * @return */ Boolean setNX(byte[] key, byte[] value); @@ -103,9 +104,9 @@ public interface RedisStringCommands { *
* See http://redis.io/commands/setex * - * @param key + * @param key must not be {@literal null}. * @param seconds - * @param value + * @param value must not be {@literal null}. */ void setEx(byte[] key, long seconds, byte[] value); @@ -114,9 +115,9 @@ public interface RedisStringCommands { *
* See http://redis.io/commands/psetex * - * @param key + * @param key must not be {@literal null}. * @param milliseconds - * @param value + * @param value must not be {@literal null}. * @since 1.3 */ void pSetEx(byte[] key, long milliseconds, byte[] value); @@ -145,7 +146,7 @@ public interface RedisStringCommands { *
* See http://redis.io/commands/incr * - * @param key + * @param key must not be {@literal null}. * @return */ Long incr(byte[] key); @@ -155,7 +156,7 @@ public interface RedisStringCommands { *
* See http://redis.io/commands/incrby * - * @param key + * @param key must not be {@literal null}. * @param value * @return */ @@ -166,7 +167,7 @@ public interface RedisStringCommands { *
* See http://redis.io/commands/incrbyfloat * - * @param key + * @param key must not be {@literal null}. * @param value * @return */ @@ -177,7 +178,7 @@ public interface RedisStringCommands { *
* See http://redis.io/commands/decr * - * @param key + * @param key must not be {@literal null}. * @return */ Long decr(byte[] key); @@ -187,7 +188,7 @@ public interface RedisStringCommands { *
* See http://redis.io/commands/decrby * - * @param key + * @param key must not be {@literal null}. * @param value * @return */ @@ -198,7 +199,7 @@ public interface RedisStringCommands { *
* See http://redis.io/commands/append * - * @param key + * @param key must not be {@literal null}. * @param value * @return */ @@ -209,7 +210,7 @@ public interface RedisStringCommands { *
* See http://redis.io/commands/getrange * - * @param key + * @param key must not be {@literal null}. * @param begin * @param end * @return @@ -221,7 +222,7 @@ public interface RedisStringCommands { *
* See http://redis.io/commands/setrange * - * @param key + * @param key must not be {@literal null}. * @param value * @param offset */ @@ -232,7 +233,7 @@ public interface RedisStringCommands { *
* See http://redis.io/commands/getbit * - * @param key + * @param key must not be {@literal null}. * @param offset * @return */ @@ -243,7 +244,7 @@ public interface RedisStringCommands { *
* See http://redis.io/commands/setbit * - * @param key + * @param key must not be {@literal null}. * @param offset * @param value * @return the original bit value stored at {@code offset}. @@ -255,7 +256,7 @@ public interface RedisStringCommands { *
* See http://redis.io/commands/bitcount * - * @param key + * @param key must not be {@literal null}. * @return */ Long bitCount(byte[] key); @@ -266,7 +267,7 @@ public interface RedisStringCommands { *
* See http://redis.io/commands/bitcount * - * @param key + * @param key must not be {@literal null}. * @param begin * @param end * @return @@ -290,7 +291,7 @@ public interface RedisStringCommands { *
* See http://redis.io/commands/strlen * - * @param key + * @param key must not be {@literal null}. * @return */ Long strLen(byte[] key); diff --git a/src/main/java/org/springframework/data/redis/connection/StringRedisConnection.java b/src/main/java/org/springframework/data/redis/connection/StringRedisConnection.java index a2f89ad53..3056c871f 100644 --- a/src/main/java/org/springframework/data/redis/connection/StringRedisConnection.java +++ b/src/main/java/org/springframework/data/redis/connection/StringRedisConnection.java @@ -1,5 +1,5 @@ /* - * Copyright 2011-2015 the original author or authors. + * Copyright 2011-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,6 +36,7 @@ import org.springframework.data.redis.serializer.RedisSerializer; * @author Christoph Strobl * @author Thomas Darimont * @author David Liu + * @author Mark Paluch * @see RedisCallback * @see RedisSerializer * @see StringRedisTemplate @@ -88,12 +89,45 @@ public interface StringRedisConnection extends RedisConnection { Long sort(String key, SortParameters params, String storeKey); + /** + * Get the value of {@code key}. + *
+ * See http://redis.io/commands/get + * + * @param key must not be {@literal null}. + * @return + */ String get(String key); + /** + * Set value of {@code key} and return its old value. + *
+ * See http://redis.io/commands/getset + * + * @param key must not be {@literal null}. + * @param value + * @return + */ String getSet(String key, String value); + /** + * Get the values of all given {@code keys}. + *
+ * See http://redis.io/commands/mget
+ *
+ * @param keys
+ * @return
+ */
List
+ * See http://redis.io/commands/set
+ *
+ * @param key must not be {@literal null}.
+ * @param value must not be {@literal null}.
+ */
void set(String key, String value);
/**
@@ -110,8 +144,26 @@ public interface StringRedisConnection extends RedisConnection {
*/
void set(String key, String value, Expiration expiration, SetOption option);
+ /**
+ * Set {@code value} for {@code key}, only if {@code key} does not exist.
+ *
+ * See http://redis.io/commands/setnx
+ *
+ * @param key must not be {@literal null}.
+ * @param value must not be {@literal null}.
+ * @return
+ */
Boolean setNX(String key, String value);
+ /**
+ * Set the {@code value} and expiration in {@code seconds} for {@code key}.
+ *
+ * See http://redis.io/commands/setex
+ *
+ * @param key must not be {@literal null}.
+ * @param seconds
+ * @param value must not be {@literal null}.
+ */
void setEx(String key, long seconds, String value);
/**
@@ -119,51 +171,185 @@ public interface StringRedisConnection extends RedisConnection {
*
* See http://redis.io/commands/psetex
*
- * @param key
+ * @param key must not be {@literal null}.
* @param milliseconds
- * @param value
+ * @param value must not be {@literal null}.
* @since 1.3
*/
void pSetEx(String key, long milliseconds, String value);
+ /**
+ * Set multiple keys to multiple values using key-value pairs provided in {@code tuple}.
+ *
+ * See http://redis.io/commands/mset
+ *
+ * @param tuple
+ */
void mSetString(Map
+ * See http://redis.io/commands/msetnx
+ *
+ * @param tuple
+ */
Boolean mSetNXString(Map
+ * See http://redis.io/commands/incr
+ *
+ * @param key must not be {@literal null}.
+ * @return
+ */
Long incr(String key);
+ /**
+ * Increment value of {@code key} by {@code value}.
+ *
+ * See http://redis.io/commands/incrby
+ *
+ * @param key must not be {@literal null}.
+ * @param value
+ * @return
+ */
Long incrBy(String key, long value);
+ /**
+ * Increment value of {@code key} by {@code value}.
+ *
+ * See http://redis.io/commands/incrbyfloat
+ *
+ * @param key must not be {@literal null}.
+ * @param value
+ * @return
+ */
Double incrBy(String key, double value);
+ /**
+ * Decrement value of {@code key} by 1.
+ *
+ * See http://redis.io/commands/decr
+ *
+ * @param key must not be {@literal null}.
+ * @return
+ */
Long decr(String key);
+ /**
+ * Increment value of {@code key} by {@code value}.
+ *
+ * See http://redis.io/commands/decrby
+ *
+ * @param key must not be {@literal null}.
+ * @param value
+ * @return
+ */
Long decrBy(String key, long value);
+ /**
+ * Append a {@code value} to {@code key}.
+ *
+ * See http://redis.io/commands/append
+ *
+ * @param key must not be {@literal null}.
+ * @param value
+ * @return
+ */
Long append(String key, String value);
+ /**
+ * Get a substring of value of {@code key} between {@code begin} and {@code end}.
+ *
+ * See http://redis.io/commands/getrange
+ *
+ * @param key must not be {@literal null}.
+ * @param start
+ * @param end
+ * @return
+ */
String getRange(String key, long start, long end);
+ /**
+ * Overwrite parts of {@code key} starting at the specified {@code offset} with given {@code value}.
+ *
+ * See http://redis.io/commands/setrange
+ *
+ * @param key must not be {@literal null}.
+ * @param value
+ * @param offset
+ */
void setRange(String key, String value, long offset);
+ /**
+ * Get the bit value at {@code offset} of value at {@code key}.
+ *
+ * See http://redis.io/commands/getbit
+ *
+ * @param key must not be {@literal null}.
+ * @param offset
+ * @return
+ */
Boolean getBit(String key, long offset);
/**
* Sets the bit at {@code offset} in value stored at {@code key}.
- *
- * @param key
+ *
+ * See http://redis.io/commands/setbit
+ *
+ * @param key must not be {@literal null}.
* @param offset
* @param value
* @return the original bit value stored at {@code offset}.
*/
Boolean setBit(String key, long offset, boolean value);
+ /**
+ * Count the number of set bits (population counting) in value stored at {@code key}.
+ *
+ * See http://redis.io/commands/bitcount
+ *
+ * @param key must not be {@literal null}.
+ * @return
+ */
Long bitCount(String key);
+ /**
+ * Count the number of set bits (population counting) of value stored at {@code key} between {@code begin} and
+ * {@code end}.
+ *
+ * See http://redis.io/commands/bitcount
+ *
+ * @param key must not be {@literal null}.
+ * @param begin
+ * @param end
+ * @return
+ */
Long bitCount(String key, long begin, long end);
+ /**
+ * Perform bitwise operations between strings.
+ *
+ * See http://redis.io/commands/bitop
+ *
+ * @param op
+ * @param destination
+ * @param keys
+ * @return
+ */
Long bitOp(BitOperation op, String destination, String... keys);
+ /**
+ * Get the length of the value stored at {@code key}.
+ *
+ * See http://redis.io/commands/strlen
+ *
+ * @param key must not be {@literal null}.
+ * @return
+ */
Long strLen(String key);
Long rPush(String key, String... values);
@@ -340,7 +526,7 @@ public interface StringRedisConnection extends RedisConnection {
/**
* @since 1.4
* @see RedisHashCommands#hScan(byte[], ScanOptions)
- * @param key
+ * @param key must not be {@literal null}.
* @param options
* @return
*/
@@ -349,7 +535,7 @@ public interface StringRedisConnection extends RedisConnection {
/**
* @since 1.4
* @see RedisSetCommands#sScan(byte[], ScanOptions)
- * @param key
+ * @param key must not be {@literal null}.
* @param options
* @return
*/
@@ -358,7 +544,7 @@ public interface StringRedisConnection extends RedisConnection {
/**
* @since 1.4
* @see RedisZSetCommands#zScan(byte[], ScanOptions)
- * @param key
+ * @param key must not be {@literal null}.
* @param options
* @return
*/
@@ -366,7 +552,7 @@ public interface StringRedisConnection extends RedisConnection {
/**
* @since 1.5
- * @param key
+ * @param key must not be {@literal null}.
* @param min
* @param max
* @return
@@ -375,7 +561,7 @@ public interface StringRedisConnection extends RedisConnection {
/**
* @since 1.5
- * @param key
+ * @param key must not be {@literal null}.
* @param min
* @param max
* @param offset
@@ -387,7 +573,7 @@ public interface StringRedisConnection extends RedisConnection {
/**
* Adds given {@literal values} to the HyperLogLog stored at given {@literal key}.
*
- * @param key
+ * @param key must not be {@literal null}.
* @param values
* @return
* @since 1.5