DATAREDIS-532 - Enhance JavaDoc and convert links to Redis documentation.

Extend JavaDoc documentation for Command/Connection/Operation interfaces. Align method ordering in operation interfaces with connection/commands interfaces.
This commit is contained in:
Mark Paluch
2017-01-11 21:53:55 +01:00
parent 154f74c408
commit 0999c04332
30 changed files with 3656 additions and 1397 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014 the original author or authors.
* Copyright 2014-2017 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.
@@ -19,6 +19,7 @@ package org.springframework.data.redis.connection;
* {@literal HyperLogLog} specific commands supported by Redis.
*
* @author Christoph Strobl
* @author Mark Paluch
* @since 1.5
*/
public interface HyperLogLogCommands {
@@ -26,25 +27,28 @@ public interface HyperLogLogCommands {
/**
* Adds given {@literal values} to the HyperLogLog stored at given {@literal key}.
*
* @param key
* @param values
* @param key must not be {@literal null}.
* @param values must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/pfadd">Redis Documentation: PFADD</a>
*/
Long pfAdd(byte[] key, byte[]... values);
/**
* Return the approximated cardinality of the structures observed by the HyperLogLog at {@literal key(s)}.
*
* @param keys
* @param keys must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/pfcount">Redis Documentation: PFCOUNT</a>
*/
Long pfCount(byte[]... keys);
/**
* Merge N different HyperLogLogs at {@literal sourceKeys} into a single {@literal destinationKey}.
*
* @param destinationKey
* @param sourceKeys
* @param destinationKey must not be {@literal null}.
* @param sourceKeys must not be {@literal null}.
* @see <a href="http://redis.io/commands/pfmerge">Redis Documentation: PFMERGE</a>
*/
void pfMerge(byte[] destinationKey, byte[]... sourceKeys);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2017 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 @@ public interface RedisClusterCommands {
* Retrieve cluster node information such as {@literal id}, {@literal host}, {@literal port} and {@literal slots}.
*
* @return never {@literal null}.
* @see <a href="https://redis.io/commands/cluster-nodes">Redis Documentation: CLUSTER NODES</a>
*/
Iterable<RedisClusterNode> clusterGetNodes();
@@ -44,6 +45,7 @@ public interface RedisClusterCommands {
*
* @param master must not be {@literal null}.
* @return never {@literal null}.
* @see <a href="https://redis.io/commands/cluster-slaves">Redis Documentation: CLUSTER SLAVES</a>
*/
Collection<RedisClusterNode> clusterGetSlaves(RedisClusterNode master);
@@ -51,6 +53,7 @@ public interface RedisClusterCommands {
* Retrieve information about masters and their connected slaves.
*
* @return never {@literal null}.
* @see <a href="https://redis.io/commands/cluster-slaves">Redis Documentation: CLUSTER SLAVES</a>
*/
Map<RedisClusterNode, Collection<RedisClusterNode>> clusterGetMasterSlaveMap();
@@ -59,6 +62,7 @@ public interface RedisClusterCommands {
*
* @param key must not be {@literal null}.
* @return
* @see <a href="https://redis.io/commands/cluster-keyslot">Redis Documentation: CLUSTER KEYSLOT</a>
*/
Integer clusterGetSlotForKey(byte[] key);
@@ -82,6 +86,7 @@ public interface RedisClusterCommands {
* Get cluster information.
*
* @return
* @see <a href="https://redis.io/commands/cluster-info">Redis Documentation: CLUSTER INFO</a>
*/
ClusterInfo clusterGetClusterInfo();
@@ -90,6 +95,7 @@ public interface RedisClusterCommands {
*
* @param node must not be {@literal null}.
* @param slots
* @see <a href="https://redis.io/commands/cluster-addslots">Redis Documentation: CLUSTER ADDSLOTS</a>
*/
void clusterAddSlots(RedisClusterNode node, int... slots);
@@ -98,6 +104,7 @@ public interface RedisClusterCommands {
*
* @param node must not be {@literal null}.
* @param range must not be {@literal null}.
* @see <a href="https://redis.io/commands/cluster-addslots">Redis Documentation: CLUSTER ADDSLOTS</a>
*/
void clusterAddSlots(RedisClusterNode node, SlotRange range);
@@ -106,6 +113,7 @@ public interface RedisClusterCommands {
*
* @param slot
* @return
* @see <a href="https://redis.io/commands/cluster-countkeysinslot">Redis Documentation: CLUSTER COUNTKEYSINSLOT</a>
*/
Long clusterCountKeysInSlot(int slot);
@@ -114,6 +122,7 @@ public interface RedisClusterCommands {
*
* @param node must not be {@literal null}.
* @param slots
* @see <a href="https://redis.io/commands/cluster-delslots">Redis Documentation: CLUSTER DELSLOTS</a>
*/
void clusterDeleteSlots(RedisClusterNode node, int... slots);
@@ -122,6 +131,7 @@ public interface RedisClusterCommands {
*
* @param node must not be {@literal null}.
* @param range must not be {@literal null}.
* @see <a href="https://redis.io/commands/cluster-delslots">Redis Documentation: CLUSTER DELSLOTS</a>
*/
void clusterDeleteSlotsInRange(RedisClusterNode node, SlotRange range);
@@ -129,6 +139,7 @@ public interface RedisClusterCommands {
* Remove given {@literal node} from cluster.
*
* @param node must not be {@literal null}.
* @see <a href="https://redis.io/commands/cluster-forget">Redis Documentation: CLUSTER FORGET</a>
*/
void clusterForget(RedisClusterNode node);
@@ -137,6 +148,7 @@ public interface RedisClusterCommands {
*
* @param node must contain {@link RedisClusterNode#getHost() host} and {@link RedisClusterNode#getPort()} and must
* not be {@literal null}.
* @see <a href="https://redis.io/commands/cluster-meet">Redis Documentation: CLUSTER MEET</a>
*/
void clusterMeet(RedisClusterNode node);
@@ -144,6 +156,7 @@ public interface RedisClusterCommands {
* @param node must not be {@literal null}.
* @param slot
* @param mode must not be{@literal null}.
* @see <a href="https://redis.io/commands/cluster-setslot">Redis Documentation: CLUSTER SETSLOT</a>
*/
void clusterSetSlot(RedisClusterNode node, int slot, AddSlots mode);
@@ -153,6 +166,7 @@ public interface RedisClusterCommands {
* @param slot
* @param count must not be {@literal null}.
* @return
* @see <a href="https://redis.io/commands/cluster-getkeysinslot">Redis Documentation: CLUSTER GETKEYSINSLOT</a>
*/
List<byte[]> clusterGetKeysInSlot(int slot, Integer count);
@@ -161,6 +175,7 @@ public interface RedisClusterCommands {
*
* @param master must not be {@literal null}.
* @param slave must not be {@literal null}.
* @see <a href="https://redis.io/commands/cluster-replicate">Redis Documentation: CLUSTER REPLICATE</a>
*/
void clusterReplicate(RedisClusterNode master, RedisClusterNode slave);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2014 the original author or authors.
* Copyright 2011-2017 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.
@@ -20,34 +20,32 @@ package org.springframework.data.redis.connection;
*
* @author Costin Leau
* @author Christoph Strobl
* @author Mark Paluch
*/
public interface RedisConnectionCommands {
/**
* Select the DB with given positive {@code dbIndex}.
* <p>
* See http://redis.io/commands/select
*
* @param dbIndex
*
* @param dbIndex the database index.
* @see <a href="http://redis.io/commands/select">Redis Documentation: SELECT</a>
*/
void select(int dbIndex);
/**
* Returns {@code message} via server roundtrip.
* <p>
* See http://redis.io/commands/echo
*
* @param message
*
* @param message the message to echo.
* @return
* @see <a href="http://redis.io/commands/echo">Redis Documentation: ECHO</a>
*/
byte[] echo(byte[] message);
/**
* Test connection.
* <p>
* See http://redis.io/commands/ping
*
*
* @return Server response message - usually {@literal PONG}.
* @see <a href="http://redis.io/commands/ping">Redis Documentation: PING</a>
*/
String ping();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 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.
@@ -15,6 +15,9 @@
*/
package org.springframework.data.redis.connection;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
@@ -28,14 +31,12 @@ import org.springframework.data.geo.Metric;
import org.springframework.data.geo.Point;
import org.springframework.util.Assert;
import lombok.Data;
import lombok.RequiredArgsConstructor;
/**
* Geo-specific Redis commands.
*
* @author Ninad Divadkar
* @author Christoph Strobl
* @author Mark Paluch
* @since 1.8
*/
public interface RedisGeoCommands {
@@ -47,7 +48,7 @@ public interface RedisGeoCommands {
* @param point must not be {@literal null}.
* @param member must not be {@literal null}.
* @return Number of elements added.
* @see <a href="http://redis.io/commands/geoadd">http://redis.io/commands/geoadd</a>
* @see <a href="http://redis.io/commands/geoadd">Redis Documentation: GEOADD</a>
*/
Long geoAdd(byte[] key, Point point, byte[] member);
@@ -57,7 +58,7 @@ public interface RedisGeoCommands {
* @param key must not be {@literal null}.
* @param location must not be {@literal null}.
* @return Number of elements added.
* @see <a href="http://redis.io/commands/geoadd">http://redis.io/commands/geoadd</a>
* @see <a href="http://redis.io/commands/geoadd">Redis Documentation: GEOADD</a>
*/
Long geoAdd(byte[] key, GeoLocation<byte[]> location);
@@ -67,7 +68,7 @@ public interface RedisGeoCommands {
* @param key must not be {@literal null}.
* @param memberCoordinateMap must not be {@literal null}.
* @return Number of elements added.
* @see <a href="http://redis.io/commands/geoadd">http://redis.io/commands/geoadd</a>
* @see <a href="http://redis.io/commands/geoadd">Redis Documentation: GEOADD</a>
*/
Long geoAdd(byte[] key, Map<byte[], Point> memberCoordinateMap);
@@ -77,7 +78,7 @@ public interface RedisGeoCommands {
* @param key must not be {@literal null}.
* @param locations must not be {@literal null}.
* @return Number of elements added.
* @see <a href="http://redis.io/commands/geoadd">http://redis.io/commands/geoadd</a>
* @see <a href="http://redis.io/commands/geoadd">Redis Documentation: GEOADD</a>
*/
Long geoAdd(byte[] key, Iterable<GeoLocation<byte[]>> locations);
@@ -88,7 +89,7 @@ public interface RedisGeoCommands {
* @param member1 must not be {@literal null}.
* @param member2 must not be {@literal null}.
* @return can be {@literal null}.
* @see <a href="http://redis.io/commands/geodist">http://redis.io/commands/geodist</a>
* @see <a href="http://redis.io/commands/geodist">Redis Documentation: GEODIST</a>
*/
Distance geoDist(byte[] key, byte[] member1, byte[] member2);
@@ -100,7 +101,7 @@ public interface RedisGeoCommands {
* @param member2 must not be {@literal null}.
* @param metric must not be {@literal null}.
* @return can be {@literal null}.
* @see <a href="http://redis.io/commands/geodist">http://redis.io/commands/geodist</a>
* @see <a href="http://redis.io/commands/geodist">Redis Documentation: GEODIST</a>
*/
Distance geoDist(byte[] key, byte[] member1, byte[] member2, Metric metric);
@@ -110,7 +111,7 @@ public interface RedisGeoCommands {
* @param key must not be {@literal null}.
* @param members must not be {@literal null}.
* @return never {@literal null}.
* @see <a href="http://redis.io/commands/geohash">http://redis.io/commands/geohash</a>
* @see <a href="http://redis.io/commands/geohash">Redis Documentation: GEOHASH</a>
*/
List<String> geoHash(byte[] key, byte[]... members);
@@ -120,7 +121,7 @@ public interface RedisGeoCommands {
* @param key must not be {@literal null}.
* @param members must not be {@literal null}.
* @return never {@literal null}.
* @see <a href="http://redis.io/commands/geopos">http://redis.io/commands/geopos</a>
* @see <a href="http://redis.io/commands/geopos">Redis Documentation: GEOPOS</a>
*/
List<Point> geoPos(byte[] key, byte[]... members);
@@ -130,7 +131,7 @@ public interface RedisGeoCommands {
* @param key must not be {@literal null}.
* @param within must not be {@literal null}.
* @return never {@literal null}.
* @see <a href="http://redis.io/commands/georadius">http://redis.io/commands/georadius</a>
* @see <a href="http://redis.io/commands/georadius">Redis Documentation: GEORADIUS</a>
*/
GeoResults<GeoLocation<byte[]>> geoRadius(byte[] key, Circle within);
@@ -141,7 +142,7 @@ public interface RedisGeoCommands {
* @param within must not be {@literal null}.
* @param args must not be {@literal null}.
* @return never {@literal null}.
* @see <a href="http://redis.io/commands/georadius">http://redis.io/commands/georadius</a>
* @see <a href="http://redis.io/commands/georadius">Redis Documentation: GEORADIUS</a>
*/
GeoResults<GeoLocation<byte[]>> geoRadius(byte[] key, Circle within, GeoRadiusCommandArgs args);
@@ -153,7 +154,7 @@ public interface RedisGeoCommands {
* @param member must not be {@literal null}.
* @param radius
* @return never {@literal null}.
* @see <a href="http://redis.io/commands/georadiusbymember">http://redis.io/commands/georadiusbymember</a>
* @see <a href="http://redis.io/commands/georadiusbymember">Redis Documentation: GEORADIUSBYMEMBER</a>
*/
GeoResults<GeoLocation<byte[]>> geoRadiusByMember(byte[] key, byte[] member, double radius);
@@ -165,7 +166,7 @@ public interface RedisGeoCommands {
* @param member must not be {@literal null}.
* @param radius must not be {@literal null}.
* @return never {@literal null}.
* @see <a href="http://redis.io/commands/georadiusbymember">http://redis.io/commands/georadiusbymember</a>
* @see <a href="http://redis.io/commands/georadiusbymember">Redis Documentation: GEORADIUSBYMEMBER</a>
*/
GeoResults<GeoLocation<byte[]>> geoRadiusByMember(byte[] key, byte[] member, Distance radius);
@@ -178,7 +179,7 @@ public interface RedisGeoCommands {
* @param radius must not be {@literal null}.
* @param args must not be {@literal null}.
* @return never {@literal null}.
* @see <a href="http://redis.io/commands/georadiusbymember">http://redis.io/commands/georadiusbymember</a>
* @see <a href="http://redis.io/commands/georadiusbymember">Redis Documentation: GEORADIUSBYMEMBER</a>
*/
GeoResults<GeoLocation<byte[]>> geoRadiusByMember(byte[] key, byte[] member, Distance radius,
GeoRadiusCommandArgs args);
@@ -189,6 +190,7 @@ public interface RedisGeoCommands {
* @param key must not be {@literal null}.
* @param members must not be {@literal null}.
* @return Number of elements removed.
* @see <a href="http://redis.io/commands/zrem">Redis Documentation: ZREM</a>
*/
Long geoRemove(byte[] key, byte[]... members);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2014 the original author or authors.
* Copyright 2011-2017 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.
@@ -27,146 +27,147 @@ import org.springframework.data.redis.core.ScanOptions;
*
* @author Costin Leau
* @author Christoph Strobl
* @author Mark Paluch
*/
public interface RedisHashCommands {
/**
* Set the {@code value} of a hash {@code field}.
*
* @see http://redis.io/commands/hset
* @param key
* @param field
* @param key must not be {@literal null}.
* @param field must not be {@literal null}.
* @param value
* @return
* @see <a href="http://redis.io/commands/hset">Redis Documentation: HSET</a>
*/
Boolean hSet(byte[] key, byte[] field, byte[] value);
/**
* Set the {@code value} of a hash {@code field} only if {@code field} does not exist.
*
* @see http://redis.io/commands/hsetnx
* @param key
* @param field
* @param key must not be {@literal null}.
* @param field must not be {@literal null}.
* @param value
* @return
* @see <a href="http://redis.io/commands/hsetnx">Redis Documentation: HSETNX</a>
*/
Boolean hSetNX(byte[] key, byte[] field, byte[] value);
/**
* Get value for given {@code field} from hash at {@code key}.
*
* @see http://redis.io/commands/hget
* @param key
* @param field
* @param key must not be {@literal null}.
* @param field must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/hget">Redis Documentation: HGET</a>
*/
byte[] hGet(byte[] key, byte[] field);
/**
* Get values for given {@code fields} from hash at {@code key}.
*
* @see http://redis.io/commands/hmget
* @param key
* @param fields
* @param key must not be {@literal null}.
* @param fields must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/hmget">Redis Documentation: HMGET</a>
*/
List<byte[]> hMGet(byte[] key, byte[]... fields);
/**
* Set multiple hash fields to multiple values using data provided in {@code hashes}
*
* @see http://redis.io/commands/hmset
* @param key
* @param hashes
* @param key must not be {@literal null}.
* @param hashes must not be {@literal null}.
* @see <a href="http://redis.io/commands/hmset">Redis Documentation: HMSET</a>
*/
void hMSet(byte[] key, Map<byte[], byte[]> hashes);
/**
* Increment {@code value} of a hash {@code field} by the given {@code delta}.
*
* @see http://redis.io/commands/hincrby
* @param key
* @param field
* @param key must not be {@literal null}.
* @param field must not be {@literal null}.
* @param delta
* @return
* @see <a href="http://redis.io/commands/hincrby">Redis Documentation: HINCRBY</a>
*/
Long hIncrBy(byte[] key, byte[] field, long delta);
/**
* Increment {@code value} of a hash {@code field} by the given {@code delta}.
*
* @see http://redis.io/commands/hincrbyfloat
* @param key
* @param key must not be {@literal null}.
* @param field
* @param delta
* @return
* @see <a href="http://redis.io/commands/hincrbyfloat">Redis Documentation: HINCRBYFLOAT</a>
*/
Double hIncrBy(byte[] key, byte[] field, double delta);
/**
* Determine if given hash {@code field} exists.
*
* @see http://redis.io/commands/hexits
* @param key
* @param field
* @param key must not be {@literal null}.
* @param field must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/hexits">Redis Documentation: HEXISTS</a>
*/
Boolean hExists(byte[] key, byte[] field);
/**
* Delete given hash {@code fields}.
*
* @see http://redis.io/commands/hdel
* @param key
* @param fields
*
* @param key must not be {@literal null}.
* @param fields must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/hdel">Redis Documentation: HDEL</a>
*/
Long hDel(byte[] key, byte[]... fields);
/**
* Get size of hash at {@code key}.
*
* @see http://redis.io/commands/hlen
* @param key
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/hlen">Redis Documentation: HLEN</a>
*/
Long hLen(byte[] key);
/**
* Get key set (fields) of hash at {@code key}.
*
* @see http://redis.io/commands/h?
* @param key
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/hkeys">Redis Documentation: HKEYS</a>?
*/
Set<byte[]> hKeys(byte[] key);
/**
* Get entry set (values) of hash at {@code field}.
*
* @see http://redis.io/commands/hvals
* @param key
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/hvals">Redis Documentation: HVALS</a>
*/
List<byte[]> hVals(byte[] key);
/**
* Get entire hash stored at {@code key}.
*
* @see http://redis.io/commands/hgetall
* @param key
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/hgetall">Redis Documentation: HGETALL</a>
*/
Map<byte[], byte[]> hGetAll(byte[] key);
/**
* Use a {@link Cursor} to iterate over entries in hash at {@code key}.
*
* @since 1.4
* @see http://redis.io/commands/scan
* @param key
* @param options
* @param key must not be {@literal null}.
* @param options must not be {@literal null}.
* @return
* @since 1.4
* @see <a href="http://redis.io/commands/hscan">Redis Documentation: HSCAN</a>
*/
Cursor<Map.Entry<byte[], byte[]>> hScan(byte[] key, ScanOptions options);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2016 the original author or authors.
* Copyright 2011-2017 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.
@@ -33,235 +33,213 @@ public interface RedisKeyCommands {
/**
* Determine if given {@code key} exists.
* <p>
* See http://redis.io/commands/exists
*
* @param key
*
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/exists">Redis Documentation: EXISTS</a>
*/
Boolean exists(byte[] key);
/**
* Delete given {@code keys}.
* <p>
* See http://redis.io/commands/del
*
* @param keys
*
* @param keys must not be {@literal null}.
* @return The number of keys that were removed.
* @see <a href="http://redis.io/commands/del">Redis Documentation: DEL</a>
*/
Long del(byte[]... keys);
/**
* Determine the type stored at {@code key}.
* <p>
* See http://redis.io/commands/type
*
* @param key
*
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/type">Redis Documentation: TYPE</a>
*/
DataType type(byte[] key);
/**
* Find all keys matching the given {@code pattern}.
* <p>
* See http://redis.io/commands/keys
*
* @param pattern
*
* @param pattern must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/keys">Redis Documentation: KEYS</a>
*/
Set<byte[]> keys(byte[] pattern);
/**
* Use a {@link Cursor} to iterate over keys.
* <p>
* See http://redis.io/commands/scan
*
* @param options
*
* @param options must not be {@literal null}.
* @return
* @since 1.4
* @see <a href="http://redis.io/commands/scan">Redis Documentation: SCAN</a>
*/
Cursor<byte[]> scan(ScanOptions options);
/**
* Return a random key from the keyspace.
* <p>
* See http://redis.io/commands/randomkey
*
*
* @return
* @see <a href="http://redis.io/commands/randomkey">Redis Documentation: RANDOMKEY</a>
*/
byte[] randomKey();
/**
* Rename key {@code oleName} to {@code newName}.
* <p>
* See http://redis.io/commands/rename
*
* @param oldName
* @param newName
* Rename key {@code oldName} to {@code newName}.
*
* @param oldName must not be {@literal null}.
* @param newName must not be {@literal null}.
* @see <a href="http://redis.io/commands/rename">Redis Documentation: RENAME</a>
*/
void rename(byte[] oldName, byte[] newName);
/**
* Rename key {@code oleName} to {@code newName} only if {@code newName} does not exist.
* <p>
* See http://redis.io/commands/renamenx
*
* @param oldName
* @param newName
* Rename key {@code oldName} to {@code newName} only if {@code newName} does not exist.
*
* @param oldName must not be {@literal null}.
* @param newName must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/renamenx">Redis Documentation: RENAMENX</a>
*/
Boolean renameNX(byte[] oldName, byte[] newName);
/**
* Set time to live for given {@code key} in seconds.
* <p>
* See http://redis.io/commands/expire
*
* @param key
*
* @param key must not be {@literal null}.
* @param seconds
* @return
* @see <a href="http://redis.io/commands/expire">Redis Documentation: EXPIRE</a>
*/
Boolean expire(byte[] key, long seconds);
/**
* Set time to live for given {@code key} in milliseconds.
* <p>
* See http://redis.io/commands/pexpire
*
* @param key
*
* @param key must not be {@literal null}.
* @param millis
* @return
* @see <a href="http://redis.io/commands/pexpire">Redis Documentation: PEXPIRE</a>
*/
Boolean pExpire(byte[] key, long millis);
/**
* Set the expiration for given {@code key} as a {@literal UNIX} timestamp.
* <p>
* See http://redis.io/commands/expireat
*
* @param key
*
* @param key must not be {@literal null}.
* @param unixTime
* @return
* @see <a href="http://redis.io/commands/expireat">Redis Documentation: EXPIREAT</a>
*/
Boolean expireAt(byte[] key, long unixTime);
/**
* Set the expiration for given {@code key} as a {@literal UNIX} timestamp in milliseconds.
* <p>
* See http://redis.io/commands/pexpireat
*
* @param key
*
* @param key must not be {@literal null}.
* @param unixTimeInMillis
* @return
* @see <a href="http://redis.io/commands/pexpireat">Redis Documentation: PEXPIREAT</a>
*/
Boolean pExpireAt(byte[] key, long unixTimeInMillis);
/**
* Remove the expiration from given {@code key}.
* <p>
* See http://redis.io/commands/persist
*
* @param key
*
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/persist">Redis Documentation: PERSIST</a>
*/
Boolean persist(byte[] key);
/**
* Move given {@code key} to database with {@code index}.
* <p>
* See http://redis.io/commands/move
*
* @param key
*
* @param key must not be {@literal null}.
* @param dbIndex
* @return
* @see <a href="http://redis.io/commands/move">Redis Documentation: MOVE</a>
*/
Boolean move(byte[] key, int dbIndex);
/**
* Get the time to live for {@code key} in seconds.
* <p>
* See http://redis.io/commands/ttl
*
* @param key
*
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/ttl">Redis Documentation: TTL</a>
*/
Long ttl(byte[] key);
/**
* Get the time to live for {@code key} in and convert it to the given {@link TimeUnit}.
* <p>
* See http://redis.io/commands/ttl
*
* @param key
* @param timeUnit
* @param key must not be {@literal null}.
* @param timeUnit must not be {@literal null}.
* @return
* @since 1.8
* @see <a href="http://redis.io/commands/ttl">Redis Documentation: TTL</a>
*/
Long ttl(byte[] key, TimeUnit timeUnit);
/**
* Get the precise time to live for {@code key} in milliseconds.
* <p>
* See http://redis.io/commands/pttl
*
* @param key
*
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/pttl">Redis Documentation: PTTL</a>
*/
Long pTtl(byte[] key);
/**
* Get the precise time to live for {@code key} in and convert it to the given {@link TimeUnit}.
* <p>
* See http://redis.io/commands/pttl
*
* @param key
* @param timeUnit
* @param key must not be {@literal null}.
* @param timeUnit must not be {@literal null}.
* @return
* @since 1.8
* @see <a href="http://redis.io/commands/pttl">Redis Documentation: PTTL</a>
*/
Long pTtl(byte[] key, TimeUnit timeUnit);
/**
* Sort the elements for {@code key}.
* <p>
* See http://redis.io/commands/sort
*
* @param key
* @param params
*
* @param key must not be {@literal null}.
* @param params must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/sort">Redis Documentation: SORT</a>
*/
List<byte[]> sort(byte[] key, SortParameters params);
/**
* Sort the elements for {@code key} and store result in {@code storeKey}.
* <p>
* See http://redis.io/commands/sort
*
* @param key
* @param params
* @param storeKey
* @return
*
* @param key must not be {@literal null}.
* @param params must not be {@literal null}.
* @param storeKey must not be {@literal null}.
* @return number of values.
* @see <a href="http://redis.io/commands/sort">Redis Documentation: SORT</a>
*/
Long sort(byte[] key, SortParameters params, byte[] storeKey);
/**
* Retrieve serialized version of the value stored at {@code key}.
* <p>
* See http://redis.io/commands/dump
*
* @param key
*
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/dump">Redis Documentation: DUMP</a>
*/
byte[] dump(byte[] key);
/**
* Create {@code key} using the {@code serializedValue}, previously obtained using {@link #dump(byte[])}.
* <p>
* See http://redis.io/commands/restore
*
* @param key
*
* @param key must not be {@literal null}.
* @param ttlInMillis
* @param serializedValue
* @param serializedValue must not be {@literal null}.
* @see <a href="http://redis.io/commands/restore">Redis Documentation: RESTORE</a>
*/
void restore(byte[] key, long ttlInMillis, byte[] serializedValue);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2014 the original author or authors.
* Copyright 2011-2017 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.
@@ -22,6 +22,7 @@ import java.util.List;
*
* @author Costin Leau
* @author Christoph Strobl
* @author Mark Paluch
*/
public interface RedisListCommands {
@@ -34,194 +35,180 @@ public interface RedisListCommands {
/**
* Append {@code values} to {@code key}.
* <p>
* See http://redis.io/commands/rpush
*
* @param key
*
* @param key must not be {@literal null}.
* @param values
* @return
* @see <a href="http://redis.io/commands/rpush">Redis Documentation: RPUSH</a>
*/
Long rPush(byte[] key, byte[]... values);
/**
* Prepend {@code values} to {@code key}.
* <p>
* See http://redis.io/commands/lpush
*
* @param key
*
* @param key must not be {@literal null}.
* @param values
* @return
* @see <a href="http://redis.io/commands/lpush">Redis Documentation: LPUSH</a>
*/
Long lPush(byte[] key, byte[]... values);
/**
* Append {@code} values to {@code key} only if the list exists.
* <p>
* See http://redis.io/commands/rpushx
*
* @param key
* Append {@code values} to {@code key} only if the list exists.
*
* @param key must not be {@literal null}.
* @param value
* @return
* @see <a href="http://redis.io/commands/rpushx">Redis Documentation: RPUSHX</a>
*/
Long rPushX(byte[] key, byte[] value);
/**
* Prepend {@code values} to {@code key} only if the list exists.
* <p>
* See http://redis.io/commands/lpushx
*
* @param key
*
* @param key must not be {@literal null}.
* @param value
* @return
* @see <a href="http://redis.io/commands/lpushx">Redis Documentation: LPUSHX</a>
*/
Long lPushX(byte[] key, byte[] value);
/**
* Get the size of list stored at {@code key}.
* <p>
* See http://redis.io/commands/llen
*
* @param key
*
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/llen">Redis Documentation: LLEN</a>
*/
Long lLen(byte[] key);
/**
* Get elements between {@code begin} and {@code end} from list at {@code key}.
* <p>
* See http://redis.io/commands/lrange
*
* @param key
* @param begin
* Get elements between {@code start} and {@code end} from list at {@code key}.
*
* @param key must not be {@literal null}.
* @param start
* @param end
* @return
* @see <a href="http://redis.io/commands/lrange">Redis Documentation: LRANGE</a>
*/
List<byte[]> lRange(byte[] key, long begin, long end);
List<byte[]> lRange(byte[] key, long start, long end);
/**
* Trim list at {@code key} to elements between {@code begin} and {@code end}.
* <p>
* See http://redis.io/commands/ltrim
*
* @param key
* @param begin
* Trim list at {@code key} to elements between {@code start} and {@code end}.
*
* @param key must not be {@literal null}.
* @param start
* @param end
* @see <a href="http://redis.io/commands/ltrim">Redis Documentation: LTRIM</a>
*/
void lTrim(byte[] key, long begin, long end);
void lTrim(byte[] key, long start, long end);
/**
* Get element at {@code index} form list at {@code key}.
* <p>
* See http://redis.io/commands/lindex
*
* @param key
*
* @param key must not be {@literal null}.
* @param index
* @return
* @see <a href="http://redis.io/commands/lindex">Redis Documentation: LINDEX</a>
*/
byte[] lIndex(byte[] key, long index);
/**
* Insert {@code value} {@link Position#BEFORE} or {@link Position#AFTER} existing {@code pivot} for {@code key}.
* <p>
* See http://redis.io/commands/linsert
*
* @param key
* @param where
*
* @param key must not be {@literal null}.
* @param where must not be {@literal null}.
* @param pivot
* @param value
* @return
* @see <a href="http://redis.io/commands/linsert">Redis Documentation: LINSERT</a>
*/
Long lInsert(byte[] key, Position where, byte[] pivot, byte[] value);
/**
* Set the {@code value} list element at {@code index}.
* <p>
* See http://redis.io/commands/lset
*
* @param key
*
* @param key must not be {@literal null}.
* @param index
* @param value
* @see <a href="http://redis.io/commands/lset">Redis Documentation: LSET</a>
*/
void lSet(byte[] key, long index, byte[] value);
/**
* Removes the first {@code count} occurrences of {@code value} from the list stored at {@code key}.
* <p>
* See http://redis.io/commands/lrem
*
* @param key
*
* @param key must not be {@literal null}.
* @param count
* @param value
* @return
* @see <a href="http://redis.io/commands/lrem">Redis Documentation: LREM</a>
*/
Long lRem(byte[] key, long count, byte[] value);
/**
* Removes and returns first element in list stored at {@code key}.
* <p>
* See http://redis.io/commands/lpop
*
* @param key
*
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/lpop">Redis Documentation: LPOP</a>
*/
byte[] lPop(byte[] key);
/**
* Removes and returns last element in list stored at {@code key}.
* <p>
* See http://redis.io/commands/rpop
*
* @param key
*
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/rpop">Redis Documentation: RPOP</a>
*/
byte[] rPop(byte[] key);
/**
* Removes and returns first element from lists stored at {@code keys} (see: {@link #lPop(byte[])}). <br>
* Removes and returns first element from lists stored at {@code keys}. <br>
* <b>Blocks connection</b> until element available or {@code timeout} reached.
* <p>
* See http://redis.io/commands/blpop
*
*
* @param timeout
* @param keys
* @param keys must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/blpop">Redis Documentation: BLPOP</a>
* @see #lPop(byte[])
*/
List<byte[]> bLPop(int timeout, byte[]... keys);
/**
* Removes and returns last element from lists stored at {@code keys} (see: {@link #rPop(byte[])}). <br>
* Removes and returns last element from lists stored at {@code keys}. <br>
* <b>Blocks connection</b> until element available or {@code timeout} reached.
* <p>
* See http://redis.io/commands/brpop
*
*
* @param timeout
* @param keys
* @param keys must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/brpop">Redis Documentation: BRPOP</a>
* @see #rPop(byte[])
*/
List<byte[]> bRPop(int timeout, byte[]... keys);
/**
* Remove the last element from list at {@code srcKey}, append it to {@code dstKey} and return its value.
* <p>
* See http://redis.io/commands/rpoplpush
*
* @param srcKey
* @param dstKey
*
* @param srcKey must not be {@literal null}.
* @param dstKey must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/rpoplpush">Redis Documentation: RPOPLPUSH</a>
*/
byte[] rPopLPush(byte[] srcKey, byte[] dstKey);
/**
* Remove the last element from list at {@code srcKey}, append it to {@code dstKey} and return its value (see
* {@link #rPopLPush(byte[], byte[])}). <br>
* Remove the last element from list at {@code srcKey}, append it to {@code dstKey} and return its value.
* <br>
* <b>Blocks connection</b> until element available or {@code timeout} reached.
* <p>
* See http://redis.io/commands/brpoplpush
*
*
* @param timeout
* @param srcKey
* @param dstKey
* @param srcKey must not be {@literal null}.
* @param dstKey must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/brpoplpush">Redis Documentation: BRPOPLPUSH</a>
* @see #rPopLPush(byte[], byte[])
*/
byte[] bRPopLPush(int timeout, byte[] srcKey, byte[] dstKey);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2013 the original author or authors.
* Copyright 2011-2017 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.
@@ -19,6 +19,7 @@ package org.springframework.data.redis.connection;
* PubSub-specific Redis commands.
*
* @author Costin Leau
* @author Mark Paluch
*/
public interface RedisPubSubCommands {
@@ -39,9 +40,10 @@ public interface RedisPubSubCommands {
/**
* Publishes the given message to the given channel.
*
* @param channel the channel to publish to
* @param channel the channel to publish to, must not be {@literal null}.
* @param message message to publish
* @return the number of clients that received the message
* @see <a href="http://redis.io/commands/publish">Redis Documentation: PUBLISH</a>
*/
Long publish(byte[] channel, byte[] message);
@@ -51,8 +53,9 @@ public interface RedisPubSubCommands {
* <p>
* Note that this operation is blocking and the current thread starts waiting for new messages immediately.
*
* @param listener message listener
* @param channels channel names
* @param listener message listener, must not be {@literal null}.
* @param channels channel names, must not be {@literal null}.
* @see <a href="http://redis.io/commands/subscribe">Redis Documentation: SUBSCRIBE</a>
*/
void subscribe(MessageListener listener, byte[]... channels);
@@ -63,8 +66,9 @@ public interface RedisPubSubCommands {
* <p>
* Note that this operation is blocking and the current thread starts waiting for new messages immediately.
*
* @param listener message listener
* @param patterns channel name patterns
* @param listener message listener, must not be {@literal null}.
* @param patterns channel name patterns, must not be {@literal null}.
* @see <a href="http://redis.io/commands/psubscribe">Redis Documentation: PSUBSCRIBE</a>
*/
void pSubscribe(MessageListener listener, byte[]... patterns);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2017 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.
@@ -23,81 +23,77 @@ import java.util.List;
* @author Costin Leau
* @author Christoph Strobl
* @author David Liu
* @author Mark Paluch
*/
public interface RedisScriptingCommands {
/**
* Flush lua script cache.
* <p>
* See http://redis.io/commands/script-flush
*
* @see <a href="http://redis.io/commands/script-flush">Redis Documentation: SCRIPT FLUSH</a>
*/
void scriptFlush();
/**
* Kill current lua script execution.
* <p>
* See http://redis.io/commands/script-kill
*
* @see <a href="http://redis.io/commands/script-kill">Redis Documentation: SCRIPT KILL</a>
*/
void scriptKill();
/**
* Load lua script into scripts cache, without executing it.<br>
* Execute the script by calling {@link #evalSha(String, ReturnType, int, byte[])}.
* <p>
* See http://redis.io/commands/script-load
*
* @param script
* Execute the script by calling {@link #evalSha(byte[], ReturnType, int, byte[]...)}.
*
* @param script must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/script-load">Redis Documentation: SCRIPT LOAD</a>
*/
String scriptLoad(byte[] script);
/**
* Check if given {@code scriptShas} exist in script cache.
* <p>
* See http://redis.io/commands/script-exits
*
*
* @param scriptShas
* @return one entry per given scriptSha in returned list.
* @see <a href="http://redis.io/commands/script-exists">Redis Documentation: SCRIPT EXISTS</a>
*/
List<Boolean> scriptExists(String... scriptShas);
/**
* Evaluate given {@code script}.
* <p>
* See http://redis.io/commands/eval
*
* @param script
* @param returnType
*
* @param script must not be {@literal null}.
* @param returnType must not be {@literal null}.
* @param numKeys
* @param keysAndArgs
* @param keysAndArgs must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/eval">Redis Documentation: EVAL</a>
*/
<T> T eval(byte[] script, ReturnType returnType, int numKeys, byte[]... keysAndArgs);
/**
* Evaluate given {@code scriptSha}.
* <p>
* See http://redis.io/commands/evalsha
*
* @param scriptSha
* @param returnType
*
* @param scriptSha must not be {@literal null}.
* @param returnType must not be {@literal null}.
* @param numKeys
* @param keysAndArgs
* @param keysAndArgs must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/evalsha">Redis Documentation: EVALSHA</a>
*/
<T> T evalSha(String scriptSha, ReturnType returnType, int numKeys, byte[]... keysAndArgs);
/**
* Evaluate given {@code scriptSha}.
* <p>
* See http://redis.io/commands/evalsha
*
* @param scriptSha
* @param returnType
*
* @param scriptSha must not be {@literal null}.
* @param returnType must not be {@literal null}.
* @param numKeys
* @param keysAndArgs
* @param keysAndArgs must not be {@literal null}.
* @return
* @since 1.5
* @see <a href="http://redis.io/commands/evalsha">Redis Documentation: EVALSHA</a>
*/
<T> T evalSha(byte[] scriptSha, ReturnType returnType, int numKeys, byte[]... keysAndArgs);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014 the original author or authors.
* Copyright 2014-2017 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.
@@ -18,8 +18,12 @@ package org.springframework.data.redis.connection;
import java.util.Collection;
/**
* Redis Sentinel-specific commands.
*
* @author Christoph Strobl
* @author Mark Paluch
* @since 1.4
* @see <a href="https://redis.io/topics/sentinel">Redis Sentinel Documentation</a>
*/
public interface RedisSentinelCommands {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2014 the original author or authors.
* Copyright 2011-2017 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.
@@ -26,6 +26,7 @@ import org.springframework.data.redis.core.types.RedisClientInfo;
* @author Costin Leau
* @author Christoph Strobl
* @author Thomas Darimont
* @author Mark Paluch
*/
public interface RedisServerCommands {
@@ -42,133 +43,125 @@ public interface RedisServerCommands {
/**
* Start an {@literal Append Only File} rewrite process on server.
* <p>
* See http://redis.io/commands/bgrewriteaof
*
* @deprecated As of 1.3, use {@link #bgReWriteAof}.
* @see <a href="http://redis.io/commands/bgrewriteaof">Redis Documentation: BGREWRITEAOF</a>
*/
@Deprecated
void bgWriteAof();
/**
* Start an {@literal Append Only File} rewrite process on server.
* <p>
* See http://redis.io/commands/bgrewriteaof
*
*
* @since 1.3
* @see <a href="http://redis.io/commands/bgrewriteaof">Redis Documentation: BGREWRITEAOF</a>
*/
void bgReWriteAof();
/**
* Start background saving of db on server.
* <p>
* See http://redis.io/commands/bgsave
*
* @see <a href="http://redis.io/commands/bgsave">Redis Documentation: BGSAVE</a>
*/
void bgSave();
/**
* Get time of last {@link #bgSave()} operation in seconds.
* <p>
* See http://redis.io/commands/lastsave
*
*
* @return
* @see <a href="http://redis.io/commands/lastsave">Redis Documentation: LASTSAVE</a>
*/
Long lastSave();
/**
* Synchronous save current db snapshot on server.
* <p>
* See http://redis.io/commands/save
*
* @see <a href="http://redis.io/commands/save">Redis Documentation: SAVE</a>
*/
void save();
/**
* Get the total number of available keys in currently selected database.
* <p>
* See http://redis.io/commands/dbsize
*
*
* @return
* @see <a href="http://redis.io/commands/dbsize">Redis Documentation: DBSIZE</a>
*/
Long dbSize();
/**
* Delete all keys of the currently selected database.
* <p>
* See http://redis.io/commands/flushdb
*
* @see <a href="http://redis.io/commands/flushdb">Redis Documentation: FLUSHDB</a>
*/
void flushDb();
/**
* Delete all <b>all keys</b> from <b>all databases</b>.
* <p>
* See http://redis.io/commands/flushall
*
* @see <a href="http://redis.io/commands/flushall">Redis Documentation: FLUSHALL</a>
*/
void flushAll();
/**
* Load {@literal default} server information like
* <ul>
* <li>mempory</li>
* <li>memory</li>
* <li>cpu utilization</li>
* <li>replication</li>
* </ul>
* <p>
* See http://redis.io/commands/info
*
* @return
* @see <a href="http://redis.io/commands/info">Redis Documentation: INFO</a>
*/
Properties info();
/**
* Load server information for given {@code selection}.
* <p>
* See http://redis.io/commands/info
*
*
* @return
* @see <a href="http://redis.io/commands/info">Redis Documentation: INFO</a>
*/
Properties info(String section);
/**
* Shutdown server.
* <p>
* See http://redis.io/commands/shutdown
*
* @see <a href="http://redis.io/commands/shutdown">Redis Documentation: SHUTDOWN</a>
*/
void shutdown();
/**
* Shutdown server.
* <p>
* See http://redis.io/commands/shutdown
*
*
* @see <a href="http://redis.io/commands/shutdown">Redis Documentation: SHUTDOWN</a>
* @since 1.3
*/
void shutdown(ShutdownOption option);
/**
* Load configuration parameters for given {@code pattern} from server.
* <p>
* See http://redis.io/commands/config-get
*
*
* @param pattern
* @return
* @see <a href="http://redis.io/commands/config-get">Redis Documentation: CONFIG GET</a>
*/
List<String> getConfig(String pattern);
/**
* Set server configuration for {@code param} to {@code value}.
* <p>
* See http://redis.io/commands/config-set
*
*
* @param param
* @param value
* @see <a href="http://redis.io/commands/config-set">Redis Documentation: CONFIG SET</a>
*/
void setConfig(String param, String value);
/**
* Reset statistic counters on server. <br>
* Counters can be retrieved using {@link #info()}.
* <p>
* See http://redis.io/commands/config-resetstat
*
* @see <a href="http://redis.io/commands/config-resetstat">Redis Documentation: CONFIG RESETSTAT</a>
*/
void resetConfigStats();
@@ -177,6 +170,7 @@ public interface RedisServerCommands {
*
* @return current server time in milliseconds.
* @since 1.1
* @see <a href="http://redis.io/commands/time">Redis Documentation: TIME</a>
*/
Long time();
@@ -186,6 +180,7 @@ public interface RedisServerCommands {
* @param host of connection to close.
* @param port of connection to close
* @since 1.3
* @see <a href="http://redis.io/commands/client-kill">Redis Documentation: CLIENT KILL</a>
*/
void killClient(String host, int port);
@@ -194,14 +189,14 @@ public interface RedisServerCommands {
*
* @param name
* @since 1.3
* @see <a href="http://redis.io/commands/client-setname">Redis Documentation: CLIENT SETNAME</a>
*/
void setClientName(byte[] name);
/**
* Returns the name of the current connection.
* <p>
* See http://redis.io/commands/client-getname
*
*
* @see <a href="http://redis.io/commands/client-getname">Redis Documentation: CLIENT GETNAME</a>
* @return
* @since 1.3
*/
@@ -209,50 +204,55 @@ public interface RedisServerCommands {
/**
* Request information and statistics about connected clients.
* <p>
* See http://redis.io/commands/client-list
*
*
* @return {@link List} of {@link RedisClientInfo} objects.
* @since 1.3
* @see <a href="http://redis.io/commands/client-list">Redis Documentation: CLIENT LIST</a>
*/
List<RedisClientInfo> getClientList();
/**
* Change redis replication setting to new master.
* <p>
* See http://redis.io/commands/slaveof
*
* @param host
*
* @param host must not be {@literal null}.
* @param port
* @since 1.3
* @see <a href="http://redis.io/commands/slaveof">Redis Documentation: SLAVEOF</a>
*/
void slaveOf(String host, int port);
/**
* Change server into master.
* <p>
* See http://redis.io/commands/slaveof
*
*
* @since 1.3
* @see <a href="http://redis.io/commands/slaveof">Redis Documentation: SLAVEOF</a>
*/
void slaveOfNoOne();
/**
* Atomically transfer a key from a source Redis instance to a destination Redis instance. On success the key is
* deleted from the original instance and is guaranteed to exist in the target instance.
*
* @param key must not be {@literal null}.
* @param target must not be {@literal null}.
* @param dbIndex
* @param option can be {@literal null}. Defaulted to {@link MigrateOption#COPY}.
* @since 1.7
* @see <a href="http://redis.io/commands/migrate">Redis Documentation: MIGRATE</a>
*/
void migrate(byte[] key, RedisNode target, int dbIndex, MigrateOption option);
/**
* Atomically transfer a key from a source Redis instance to a destination Redis instance. On success the key is
* deleted from the original instance and is guaranteed to exist in the target instance.
*
* @param key must not be {@literal null}.
* @param target must not be {@literal null}.
* @param dbIndex
* @param option can be {@literal null}. Defaulted to {@link MigrateOption#COPY}.
* @param timeout
* @since 1.7
* @see <a href="http://redis.io/commands/migrate">Redis Documentation: MIGRATE</a>
*/
void migrate(byte[] key, RedisNode target, int dbIndex, MigrateOption option, long timeout);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2014 the original author or authors.
* Copyright 2011-2017 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.
@@ -26,177 +26,162 @@ import org.springframework.data.redis.core.ScanOptions;
*
* @author Costin Leau
* @author Christoph Strobl
* @author Mark Paluch
*/
public interface RedisSetCommands {
/**
* Add given {@code values} to set at {@code key}.
* <p>
* See http://redis.io/commands/sadd
*
* @param key
*
* @param key must not be {@literal null}.
* @param values
* @return
* @see <a href="http://redis.io/commands/sadd">Redis Documentation: SADD</a>
*/
Long sAdd(byte[] key, byte[]... values);
/**
* Remove given {@code values} from set at {@code key} and return the number of removed elements.
* <p>
* See http://redis.io/commands/srem
*
* @param key
*
* @param key must not be {@literal null}.
* @param values
* @return
* @see <a href="http://redis.io/commands/srem">Redis Documentation: SREM</a>
*/
Long sRem(byte[] key, byte[]... values);
/**
* Remove and return a random member from set at {@code key}.
* <p>
* See http://redis.io/commands/spop
*
* @param key
*
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/spop">Redis Documentation: SPOP</a>
*/
byte[] sPop(byte[] key);
/**
* Move {@code value} from {@code srcKey} to {@code destKey}
* <p>
* See http://redis.io/commands/smove
*
* @param srcKey
* @param destKey
*
* @param srcKey must not be {@literal null}.
* @param destKey must not be {@literal null}.
* @param value
* @return
* @see <a href="http://redis.io/commands/smove">Redis Documentation: SMOVE</a>
*/
Boolean sMove(byte[] srcKey, byte[] destKey, byte[] value);
/**
* Get size of set at {@code key}.
* <p>
* See http://redis.io/commands/scard
*
* @param key
*
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/scard">Redis Documentation: SCARD</a>
*/
Long sCard(byte[] key);
/**
* Check if set at {@code key} contains {@code value}.
* <p>
* See http://redis.io/commands/sismember
*
* @param key
*
* @param key must not be {@literal null}.
* @param value
* @return
* @see <a href="http://redis.io/commands/sismember">Redis Documentation: SISMEMBER</a>
*/
Boolean sIsMember(byte[] key, byte[] value);
/**
* Returns the members intersecting all given sets at {@code keys}.
* <p>
* See http://redis.io/commands/sinter
*
* @param keys
*
* @param keys must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/sinter">Redis Documentation: SINTER</a>
*/
Set<byte[]> sInter(byte[]... keys);
/**
* Intersect all given sets at {@code keys} and store result in {@code destKey}.
* <p>
* See http://redis.io/commands/sinterstore
*
* @param destKey
* @param keys
*
* @param destKey must not be {@literal null}.
* @param keys must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/sinterstore">Redis Documentation: SINTERSTORE</a>
*/
Long sInterStore(byte[] destKey, byte[]... keys);
/**
* Union all sets at given {@code keys}.
* <p>
* See http://redis.io/commands/sunion
*
* @param keys
*
* @param keys must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/sunion">Redis Documentation: SUNION</a>
*/
Set<byte[]> sUnion(byte[]... keys);
/**
* Union all sets at given {@code keys} and store result in {@code destKey}.
* <p>
* See http://redis.io/commands/sunionstore
*
* @param destKey
* @param keys
*
* @param destKey must not be {@literal null}.
* @param keys must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/sunionstore">Redis Documentation: SUNIONSTORE</a>
*/
Long sUnionStore(byte[] destKey, byte[]... keys);
/**
* Diff all sets for given {@code keys}.
* <p>
* See http://redis.io/commands/sdiff
*
* @param keys
*
* @param keys must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/sdiff">Redis Documentation: SDIFF</a>
*/
Set<byte[]> sDiff(byte[]... keys);
/**
* Diff all sets for given {@code keys} and store result in {@code destKey}
* <p>
* See http://redis.io/commands/sdiffstore
*
* @param destKey
* @param keys
* Diff all sets for given {@code keys} and store result in {@code destKey}.
*
* @param destKey must not be {@literal null}.
* @param keys must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/sdiffstore">Redis Documentation: SDIFFSTORE</a>
*/
Long sDiffStore(byte[] destKey, byte[]... keys);
/**
* Get all elements of set at {@code key}.
* <p>
* See http://redis.io/commands/smembers
*
* @param key
*
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/smembers">Redis Documentation: SMEMBERS</a>
*/
Set<byte[]> sMembers(byte[] key);
/**
* Get random element from set at {@code key}.
* <p>
* See http://redis.io/commands/srandmember
*
* @param key
*
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/srandmember">Redis Documentation: SRANDMEMBER</a>
*/
byte[] sRandMember(byte[] key);
/**
* Get {@code count} random elements from set at {@code key}.
* <p>
* See http://redis.io/commands/srandmember
*
* @param key
*
* @param key must not be {@literal null}.
* @param count
* @return
* @see <a href="http://redis.io/commands/srandmember">Redis Documentation: SRANDMEMBER</a>
*/
List<byte[]> sRandMember(byte[] key, long count);
/**
* Use a {@link Cursor} to iterate over elements in set at {@code key}.
* <p>
* See http://redis.io/commands/scan
*
* @since 1.4
* @param key
* @param options
*
* @param key must not be {@literal null}.
* @param options must not be {@literal null}.
* @return
* @since 1.4
* @see <a href="http://redis.io/commands/scan">Redis Documentation: SCAN</a>
*/
Cursor<byte[]> sScan(byte[] key, ScanOptions options);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2016 the original author or authors.
* Copyright 2011-2017 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.
@@ -35,264 +35,240 @@ public interface RedisStringCommands {
/**
* Get the value of {@code key}.
* <p>
* See http://redis.io/commands/get
*
*
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/get">Redis Documentation: GET</a>
*/
byte[] get(byte[] key);
/**
* Set value of {@code key} and return its old value.
* <p>
* See http://redis.io/commands/getset
*
* Set {@code value} of {@code key} and return its old value.
*
* @param key must not be {@literal null}.
* @param value
* @return
* @see <a href="http://redis.io/commands/getset">Redis Documentation: GETSET</a>
*/
byte[] getSet(byte[] key, byte[] value);
/**
* Get the values of all given {@code keys}.
* <p>
* See http://redis.io/commands/mget
*
* @param keys
* Get multiple {@code keys}. Values are returned in the order of the requested keys.
*
* @param keys must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/mget">Redis Documentation: MGET</a>
*/
List<byte[]> mGet(byte[]... keys);
/**
* Set {@code value} for {@code key}.
* <p>
* See http://redis.io/commands/set
*
*
* @param key must not be {@literal null}.
* @param value must not be {@literal null}.
* @see <a href="http://redis.io/commands/set">Redis Documentation: SET</a>
*/
void set(byte[] key, byte[] value);
/**
* Set {@code value} for {@code key} applying timeouts from {@code expiration} if set and inserting/updating values
* depending on {@code option}.
* <p>
* See http://redis.io/commands/set
*
* @param key must not be {@literal null}.
* @param value must not be {@literal null}.
* @param expiration can be {@literal null}. Defaulted to {@link Expiration#persistent()}.
* @param option can be {@literal null}. Defaulted to {@link SetOption#UPSERT}.
* @since 1.7
* @see <a href="http://redis.io/commands/set">Redis Documentation: SET</a>
*/
void set(byte[] key, byte[] value, Expiration expiration, SetOption option);
/**
* Set {@code value} for {@code key}, only if {@code key} does not exist.
* <p>
* See http://redis.io/commands/setnx
*
*
* @param key must not be {@literal null}.
* @param value must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/setnx">Redis Documentation: SETNX</a>
*/
Boolean setNX(byte[] key, byte[] value);
/**
* Set the {@code value} and expiration in {@code seconds} for {@code key}.
* <p>
* See http://redis.io/commands/setex
*
*
* @param key must not be {@literal null}.
* @param seconds
* @param value must not be {@literal null}.
* @see <a href="http://redis.io/commands/setex">Redis Documentation: SETEX</a>
*/
void setEx(byte[] key, long seconds, byte[] value);
/**
* Set the {@code value} and expiration in {@code milliseconds} for {@code key}.
* <p>
* See http://redis.io/commands/psetex
*
*
* @param key must not be {@literal null}.
* @param milliseconds
* @param value must not be {@literal null}.
* @since 1.3
* @see <a href="http://redis.io/commands/psetex">Redis Documentation: PSETEX</a>
*/
void pSetEx(byte[] key, long milliseconds, byte[] value);
/**
* Set multiple keys to multiple values using key-value pairs provided in {@code tuple}.
* <p>
* See http://redis.io/commands/mset
*
* @param tuple
*
* @param tuple must not be {@literal null}.
* @see <a href="http://redis.io/commands/mset">Redis Documentation: MSET</a>
*/
void mSet(Map<byte[], byte[]> tuple);
/**
* Set multiple keys to multiple values using key-value pairs provided in {@code tuple} only if the provided key does
* not exist.
* <p>
* See http://redis.io/commands/msetnx
*
* @param tuple
*
* @param tuple must not be {@literal null}.
* @see <a href="http://redis.io/commands/msetnx">Redis Documentation: MSETNX</a>
*/
Boolean mSetNX(Map<byte[], byte[]> tuple);
/**
* Increment value of {@code key} by 1.
* <p>
* See http://redis.io/commands/incr
*
* Increment an integer value stored as string value of {@code key} by 1.
*
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/incr">Redis Documentation: INCR</a>
*/
Long incr(byte[] key);
/**
* Increment value of {@code key} by {@code value}.
* <p>
* See http://redis.io/commands/incrby
*
* Increment an integer value stored of {@code key} by {@code delta}.
*
* @param key must not be {@literal null}.
* @param value
* @return
* @see <a href="http://redis.io/commands/incrby">Redis Documentation: INCRBY</a>
*/
Long incrBy(byte[] key, long value);
/**
* Increment value of {@code key} by {@code value}.
* <p>
* See http://redis.io/commands/incrbyfloat
*
* Increment a floating point number value of {@code key} by {@code delta}.
*
* @param key must not be {@literal null}.
* @param value
* @return
* @see <a href="http://redis.io/commands/incrbyfloat">Redis Documentation: INCRBYFLOAT</a>
*/
Double incrBy(byte[] key, double value);
/**
* Decrement value of {@code key} by 1.
* <p>
* See http://redis.io/commands/decr
*
* Decrement an integer value stored as string value of {@code key} by 1.
*
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/decr">Redis Documentation: DECR</a>
*/
Long decr(byte[] key);
/**
* Increment value of {@code key} by {@code value}.
* <p>
* See http://redis.io/commands/decrby
*
* Decrement an integer value stored as string value of {@code key} by {@code value}.
*
* @param key must not be {@literal null}.
* @param value
* @return
* @see <a href="http://redis.io/commands/decrby">Redis Documentation: DECRBY</a>
*/
Long decrBy(byte[] key, long value);
/**
* Append a {@code value} to {@code key}.
* <p>
* See http://redis.io/commands/append
*
*
* @param key must not be {@literal null}.
* @param value
* @return
* @see <a href="http://redis.io/commands/append">Redis Documentation: APPEND</a>
*/
Long append(byte[] key, byte[] value);
/**
* Get a substring of value of {@code key} between {@code begin} and {@code end}.
* <p>
* See http://redis.io/commands/getrange
*
*
* @param key must not be {@literal null}.
* @param begin
* @param end
* @return
* @see <a href="http://redis.io/commands/getrange">Redis Documentation: GETRANGE</a>
*/
byte[] getRange(byte[] key, long begin, long end);
/**
* Overwrite parts of {@code key} starting at the specified {@code offset} with given {@code value}.
* <p>
* See http://redis.io/commands/setrange
*
*
* @param key must not be {@literal null}.
* @param value
* @param offset
* @see <a href="http://redis.io/commands/setrange">Redis Documentation: SETRANGE</a>
*/
void setRange(byte[] key, byte[] value, long offset);
/**
* Get the bit value at {@code offset} of value at {@code key}.
* <p>
* See http://redis.io/commands/getbit
*
*
* @param key must not be {@literal null}.
* @param offset
* @return
* @see <a href="http://redis.io/commands/getbit">Redis Documentation: GETBIT</a>
*/
Boolean getBit(byte[] key, long offset);
/**
* Sets the bit at {@code offset} in value stored at {@code key}.
* <p>
* 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}.
* @see <a href="http://redis.io/commands/setbit">Redis Documentation: SETBIT</a>
*/
Boolean setBit(byte[] key, long offset, boolean value);
/**
* Count the number of set bits (population counting) in value stored at {@code key}.
* <p>
* See http://redis.io/commands/bitcount
*
*
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/bitcount">Redis Documentation: BITCOUNT</a>
*/
Long bitCount(byte[] key);
/**
* Count the number of set bits (population counting) of value stored at {@code key} between {@code begin} and
* {@code end}.
* <p>
* See http://redis.io/commands/bitcount
*
*
* @param key must not be {@literal null}.
* @param begin
* @param end
* @return
* @see <a href="http://redis.io/commands/bitcount">Redis Documentation: BITCOUNT</a>
*/
Long bitCount(byte[] key, long begin, long end);
/**
* Perform bitwise operations between strings.
* <p>
* See http://redis.io/commands/bitop
*
* @param op
* @param destination
* @param keys
*
* @param op must not be {@literal null}.
* @param destination must not be {@literal null}.
* @param keys must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/bitop">Redis Documentation: BITOP</a>
*/
Long bitOp(BitOperation op, byte[] destination, byte[]... keys);
/**
* Get the length of the value stored at {@code key}.
* <p>
* See http://redis.io/commands/strlen
*
*
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/strlen">Redis Documentation: STRLEN</a>
*/
Long strLen(byte[] key);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2014 the original author or authors.
* Copyright 2011-2017 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.
@@ -22,6 +22,7 @@ import java.util.List;
*
* @author Costin Leau
* @author Christoph Strobl
* @author Mark Paluch
*/
public interface RedisTxCommands {
@@ -29,40 +30,39 @@ public interface RedisTxCommands {
* Mark the start of a transaction block. <br>
* Commands will be queued and can then be executed by calling {@link #exec()} or rolled back using {@link #discard()}
* <p>
* See http://redis.io/commands/multi
*
* @see <a href="http://redis.io/commands/multi">Redis Documentation: MULTI</a>
*/
void multi();
/**
* Executes all queued commands in a transaction started with {@link #multi()}. <br>
* If used along with {@link #watch(byte[])} the operation will fail if any of watched keys has been modified.
* <p>
* See http://redis.io/commands/exec
*
* If used along with {@link #watch(byte[]...)} the operation will fail if any of watched keys has been modified.
*
* @return List of replies for each executed command.
* @see <a href="http://redis.io/commands/exec">Redis Documentation: EXEC</a>
*/
List<Object> exec();
/**
* Discard all commands issued after {@link #multi()}.
* <p>
* See http://redis.io/commands/discard
*
* @see <a href="http://redis.io/commands/discard">Redis Documentation: DISCARD</a>
*/
void discard();
/**
* Watch given {@code keys} for modifications during transaction started with {@link #multi()}.
* <p>
* See http://redis.io/commands/watch
*
* @param keys
*
* @param keys must not be {@literal null}.
* @see <a href="http://redis.io/commands/watch">Redis Documentation: WATCH</a>
*/
void watch(byte[]... keys);
/**
* Flushes all the previously {@link #watch(byte[])} keys.
* <p>
* See http://redis.io/commands/unwatch
* Flushes all the previously {@link #watch(byte[]...)} keys.
*
* @see <a href="http://redis.io/commands/unwatch">Redis Documentation: UNWATCH</a>
*/
void unwatch();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2015 the original author or authors.
* Copyright 2011-2017 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.
@@ -28,6 +28,7 @@ import org.springframework.util.Assert;
* @author Christoph Strobl
* @author Thomas Darimont
* @author David Liu
* @author Mark Paluch
*/
public interface RedisZSetCommands {
@@ -202,162 +203,150 @@ public interface RedisZSetCommands {
public int getOffset() {
return offset;
}
}
/**
* Add {@code value} to a sorted set at {@code key}, or update its {@code score} if it already exists.
* <p>
* See http://redis.io/commands/zadd
*
* @param key
* @param score
* @param value
*
* @param key must not be {@literal null}.
* @param score the score.
* @param value the value.
* @return
* @see <a href="http://redis.io/commands/zadd">Redis Documentation: ZADD</a>
*/
Boolean zAdd(byte[] key, double score, byte[] value);
/**
* Add {@code tuples} to a sorted set at {@code key}, or update its {@code score} if it already exists.
* <p>
* See http://redis.io/commands/zadd
*
* @param key
* @param tuples
*
* @param key must not be {@literal null}.
* @param tuples must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/zadd">Redis Documentation: ZADD</a>
*/
Long zAdd(byte[] key, Set<Tuple> tuples);
/**
* Remove {@code values} from sorted set. Return number of removed elements.
* <p>
* See http://redis.io/commands/zrem
*
* @param key
* @param values
*
* @param key must not be {@literal null}.
* @param values must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/zrem">Redis Documentation: ZREM</a>
*/
Long zRem(byte[] key, byte[]... values);
/**
* Increment the score of element with {@code value} in sorted set by {@code increment}.
* <p>
* See http://redis.io/commands/zincrby
*
* @param key
*
* @param key must not be {@literal null}.
* @param increment
* @param value
* @param value the value.
* @return
* @see <a href="http://redis.io/commands/zincrby">Redis Documentation: ZINCRBY</a>
*/
Double zIncrBy(byte[] key, double increment, byte[] value);
/**
* Determine the index of element with {@code value} in a sorted set.
* <p>
* See http://redis.io/commands/zrank
*
* @param key
* @param value
*
* @param key must not be {@literal null}.
* @param value the value.
* @return
* @see <a href="http://redis.io/commands/zrank">Redis Documentation: ZRANK</a>
*/
Long zRank(byte[] key, byte[] value);
/**
* Determine the index of element with {@code value} in a sorted set when scored high to low.
* <p>
* See http://redis.io/commands/zrevrank
*
* @param key
* @param value
*
* @param key must not be {@literal null}.
* @param value the value.
* @return
* @see <a href="http://redis.io/commands/zrevrank">Redis Documentation: ZREVRANK</a>
*/
Long zRevRank(byte[] key, byte[] value);
/**
* Get elements between {@code begin} and {@code end} from sorted set.
* <p>
* See http://redis.io/commands/zrange
*
* @param key
* @param begin
* Get elements between {@code start} and {@code end} from sorted set.
*
* @param key must not be {@literal null}.
* @param start
* @param end
* @return
* @see <a href="http://redis.io/commands/zrange">Redis Documentation: ZRANGE</a>
*/
Set<byte[]> zRange(byte[] key, long begin, long end);
Set<byte[]> zRange(byte[] key, long start, long end);
/**
* Get set of {@link Tuple}s between {@code begin} and {@code end} from sorted set.
* <p>
* See http://redis.io/commands/zrange
*
* @param key
* @param begin
* Get set of {@link Tuple}s between {@code start} and {@code end} from sorted set.
*
* @param key must not be {@literal null}.
* @param start
* @param end
* @return
* @see <a href="http://redis.io/commands/zrange">Redis Documentation: ZRANGE</a>
*/
Set<Tuple> zRangeWithScores(byte[] key, long begin, long end);
Set<Tuple> zRangeWithScores(byte[] key, long start, long end);
/**
* Get elements where score is between {@code min} and {@code max} from sorted set.
* <p>
* See http://redis.io/commands/zrangebyscore
*
* @param key
*
* @param key must not be {@literal null}.
* @param min
* @param max
* @return
* @see <a href="http://redis.io/commands/zrangebyscore">Redis Documentation: ZRANGEBYSCORE</a>
*/
Set<byte[]> zRangeByScore(byte[] key, double min, double max);
/**
* Get set of {@link Tuple}s where score is between {@code Range#min} and {@code Range#max} from sorted set.
*
* @param key
* @param range
* @param key must not be {@literal null}.
* @param range must not be {@literal null}.
* @return
* @since 1.6
* @see <a href="http://redis.io/commands/zrangebyscore">Redis Documentation: ZRANGEBYSCORE</a>
*/
Set<Tuple> zRangeByScoreWithScores(byte[] key, Range range);
/**
* Get set of {@link Tuple}s where score is between {@code min} and {@code max} from sorted set.
* <p>
* See http://redis.io/commands/zrangebyscore
*
* @param key
*
* @param key must not be {@literal null}.
* @param min
* @param max
* @return
* @see <a href="http://redis.io/commands/zrangebyscore">Redis Documentation: ZRANGEBYSCORE</a>
*/
Set<Tuple> zRangeByScoreWithScores(byte[] key, double min, double max);
/**
* Get elements in range from {@code begin} to {@code end} where score is between {@code min} and {@code max} from
* Get elements in range from {@code start} to {@code end} where score is between {@code min} and {@code max} from
* sorted set.
* <p>
* See http://redis.io/commands/zrangebyscore
*
* @param key
*
* @param key must not be {@literal null}.
* @param min
* @param max
* @param offset
* @param count
* @return
* @see <a href="http://redis.io/commands/zrangebyscore">Redis Documentation: ZRANGEBYSCORE</a>
*/
Set<byte[]> zRangeByScore(byte[] key, double min, double max, long offset, long count);
/**
* Get set of {@link Tuple}s in range from {@code begin} to {@code end} where score is between {@code min} and
* Get set of {@link Tuple}s in range from {@code start} to {@code end} where score is between {@code min} and
* {@code max} from sorted set.
* <p>
* See http://redis.io/commands/zrangebyscore
*
*
* @param key
* @param min
* @param max
* @param offset
* @param count
* @return
* @see <a href="http://redis.io/commands/zrangebyscore">Redis Documentation: ZRANGEBYSCORE</a>
*/
Set<Tuple> zRangeByScoreWithScores(byte[] key, double min, double max, long offset, long count);
@@ -365,47 +354,45 @@ public interface RedisZSetCommands {
* Get set of {@link Tuple}s in range from {@code Limit#offset} to {@code Limit#offset + Limit#count} where score is
* between {@code Range#min} and {@code Range#max} from sorted set.
*
* @param key
* @param range
* @param key must not be {@literal null}.
* @param range must not be {@literal null}.
* @param limit
* @return
* @since 1.6
* @see <a href="http://redis.io/commands/zrangebyscore">Redis Documentation: ZRANGEBYSCORE</a>
*/
Set<Tuple> zRangeByScoreWithScores(byte[] key, Range range, Limit limit);
/**
* Get elements in range from {@code begin} to {@code end} from sorted set ordered from high to low.
* <p>
* See http://redis.io/commands/zrevrange
*
* @param key
* @param begin
* Get elements in range from {@code start} to {@code end} from sorted set ordered from high to low.
*
* @param key must not be {@literal null}.
* @param start
* @param end
* @return
* @see <a href="http://redis.io/commands/zrevrange">Redis Documentation: ZREVRANGE</a>
*/
Set<byte[]> zRevRange(byte[] key, long begin, long end);
Set<byte[]> zRevRange(byte[] key, long start, long end);
/**
* Get set of {@link Tuple}s in range from {@code begin} to {@code end} from sorted set ordered from high to low.
* <p>
* See http://redis.io/commands/zrevrange
*
* @param key
* @param begin
* Get set of {@link Tuple}s in range from {@code start} to {@code end} from sorted set ordered from high to low.
*
* @param key must not be {@literal null}.
* @param start
* @param end
* @return
* @see <a href="http://redis.io/commands/zrevrange">Redis Documentation: ZREVRANGE</a>
*/
Set<Tuple> zRevRangeWithScores(byte[] key, long begin, long end);
Set<Tuple> zRevRangeWithScores(byte[] key, long start, long end);
/**
* Get elements where score is between {@code min} and {@code max} from sorted set ordered from high to low.
* <p>
* See http://redis.io/commands/zrevrange
*
* @param key
*
* @param key must not be {@literal null}.
* @param min
* @param max
* @return
* @see <a href="http://redis.io/commands/zrevrange">Redis Documentation: ZREVRANGE</a>
*/
Set<byte[]> zRevRangeByScore(byte[] key, double min, double max);
@@ -413,306 +400,303 @@ public interface RedisZSetCommands {
* Get elements where score is between {@code Range#min} and {@code Range#max} from sorted set ordered from high to
* low.
*
* @param key
* @param range
* @param key must not be {@literal null}.
* @param range must not be {@literal null}.
* @return
* @since 1.6
* @see <a href="http://redis.io/commands/zrevrangebyscore">Redis Documentation: ZREVRANGEBYSCORE</a>
*/
Set<byte[]> zRevRangeByScore(byte[] key, Range range);
/**
* Get set of {@link Tuple} where score is between {@code min} and {@code max} from sorted set ordered from high to
* low.
* <p>
* See http://redis.io/commands/zrevrange
*
* @param key
*
* @param key must not be {@literal null}.
* @param min
* @param max
* @return
* @see <a href="http://redis.io/commands/zrevrangebyscore">Redis Documentation: ZREVRANGEBYSCORE</a>
*/
Set<Tuple> zRevRangeByScoreWithScores(byte[] key, double min, double max);
/**
* Get elements in range from {@code begin} to {@code end} where score is between {@code min} and {@code max} from
* Get elements in range from {@code start} to {@code end} where score is between {@code min} and {@code max} from
* sorted set ordered high -> low.
* <p>
* See http://redis.io/commands/zrevrangebyscore
*
* @param key
*
* @param key must not be {@literal null}.
* @param min
* @param max
* @param offset
* @param count
* @return
* @see <a href="http://redis.io/commands/zrevrangebyscore">Redis Documentation: ZREVRANGEBYSCORE</a>
*/
Set<byte[]> zRevRangeByScore(byte[] key, double min, double max, long offset, long count);
/**
* Get elements in range from {@code Limit#offset} to {@code Limit#offset + Limit#count} where score is between
* {@code Range#min} and {@code Range#max} from sorted set ordered high -> low.
*
* @param key
* @param range
*
* @param key must not be {@literal null}.
* @param range must not be {@literal null}.
* @param limit
* @return
* @since 1.6
* @see <a href="http://redis.io/commands/zrevrangebyscore">Redis Documentation: ZREVRANGEBYSCORE</a>
*/
Set<byte[]> zRevRangeByScore(byte[] key, Range range, Limit limit);
/**
* Get set of {@link Tuple} in range from {@code begin} to {@code end} where score is between {@code min} and
* Get set of {@link Tuple} in range from {@code start} to {@code end} where score is between {@code min} and
* {@code max} from sorted set ordered high -> low.
* <p>
* See http://redis.io/commands/zrevrangebyscore
*
* @param key
*
* @param key must not be {@literal null}.
* @param min
* @param max
* @param offset
* @param count
* @return
* @see <a href="http://redis.io/commands/zrevrangebyscore">Redis Documentation: ZREVRANGEBYSCORE</a>
*/
Set<Tuple> zRevRangeByScoreWithScores(byte[] key, double min, double max, long offset, long count);
/**
* Get set of {@link Tuple} where score is between {@code Range#min} and {@code Range#max} from sorted set ordered
* from high to low.
*
* @param key
* @param range
*
* @param key must not be {@literal null}.
* @param range must not be {@literal null}.
* @return
* @since 1.6
* @see <a href="http://redis.io/commands/zrevrangebyscore">Redis Documentation: ZREVRANGEBYSCORE</a>
*/
Set<Tuple> zRevRangeByScoreWithScores(byte[] key, Range range);
/**
* Get set of {@link Tuple} in range from {@code Limit#offset} to {@code Limit#count} where score is between
* {@code Range#min} and {@code Range#max} from sorted set ordered high -> low.
*
* @param key
* @param range
*
* @param key must not be {@literal null}.
* @param range must not be {@literal null}.
* @param limit
* @return
* @since 1.6
* @see <a href="http://redis.io/commands/zrevrangebyscore">Redis Documentation: ZREVRANGEBYSCORE</a>
*/
Set<Tuple> zRevRangeByScoreWithScores(byte[] key, Range range, Limit limit);
/**
* Count number of elements within sorted set with scores between {@code min} and {@code max}.
* <p>
* See http://redis.io/commands/zcount
*
* @param key
*
* @param key must not be {@literal null}.
* @param min
* @param max
* @return
* @see <a href="http://redis.io/commands/zcount">Redis Documentation: ZCOUNT</a>
*/
Long zCount(byte[] key, double min, double max);
/**
* Count number of elements within sorted set with scores between {@code Range#min} and {@code Range#max}.
*
* @param key
* @param min
* @param max
*
* @param key must not be {@literal null}.
* @param range must not be {@literal null}.
* @return
* @since 1.6
* @see <a href="http://redis.io/commands/zcount">Redis Documentation: ZCOUNT</a>
*/
Long zCount(byte[] key, Range range);
/**
* Get the size of sorted set with {@code key}.
* <p>
* See http://redis.io/commands/zcard
*
* @param key
*
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/zcard">Redis Documentation: ZCARD</a>
*/
Long zCard(byte[] key);
/**
* Get the score of element with {@code value} from sorted set with key {@code key}.
* <p>
* See http://redis.io/commands/zrem
*
* @param key
* @param value
* @param key must not be {@literal null}.
* @param value the value.
* @return
* @see <a href="http://redis.io/commands/zrem">Redis Documentation: ZREM</a>
*/
Double zScore(byte[] key, byte[] value);
/**
* Remove elements in range between {@code begin} and {@code end} from sorted set with {@code key}.
* <p>
* See http://redis.io/commands/zremrange
* Remove elements in range between {@code start} and {@code end} from sorted set with {@code key}.
*
* @param key
* @param begin
* @param key must not be {@literal null}.
* @param start
* @param end
* @return
* @see <a href="http://redis.io/commands/zremrangebyrank">Redis Documentation: ZREMRANGEBYRANK</a>
*/
Long zRemRange(byte[] key, long begin, long end);
Long zRemRange(byte[] key, long start, long end);
/**
* Remove elements with scores between {@code min} and {@code max} from sorted set with {@code key}.
* <p>
* See http://redis.io/commands/zremrangebyscore
*
* @param key
*
* @param key must not be {@literal null}.
* @param min
* @param max
* @return
* @see <a href="http://redis.io/commands/zremrangebyscore">Redis Documentation: ZREMRANGEBYSCORE</a>
*/
Long zRemRangeByScore(byte[] key, double min, double max);
/**
* Remove elements with scores between {@code Range#min} and {@code Range#max} from sorted set with {@code key}.
*
* @param key
* @param range
*
* @param key must not be {@literal null}.
* @param range must not be {@literal null}.
* @return
* @since 1.6
* @see <a href="http://redis.io/commands/zremrangebyscore">Redis Documentation: ZREMRANGEBYSCORE</a>
*/
Long zRemRangeByScore(byte[] key, Range range);
/**
* Union sorted {@code sets} and store result in destination {@code key}.
* <p>
* See http://redis.io/commands/zunionstore
*
* @param destKey
* @param sets
*
* @param destKey must not be {@literal null}.
* @param sets must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/zunionstore">Redis Documentation: ZUNIONSTORE</a>
*/
Long zUnionStore(byte[] destKey, byte[]... sets);
/**
* Union sorted {@code sets} and store result in destination {@code key}.
* <p>
* See http://redis.io/commands/zunionstore
*
* @param destKey
* @param aggregate
*
* @param destKey must not be {@literal null}.
* @param aggregate must not be {@literal null}.
* @param weights
* @param sets
* @param sets must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/zunionstore">Redis Documentation: ZUNIONSTORE</a>
*/
Long zUnionStore(byte[] destKey, Aggregate aggregate, int[] weights, byte[]... sets);
/**
* Intersect sorted {@code sets} and store result in destination {@code key}.
* <p>
* See http://redis.io/commands/zinterstore
*
* @param destKey
* @param sets
*
* @param destKey must not be {@literal null}.
* @param sets must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/zinterstore">Redis Documentation: ZINTERSTORE</a>
*/
Long zInterStore(byte[] destKey, byte[]... sets);
/**
* Intersect sorted {@code sets} and store result in destination {@code key}.
* <p>
* See http://redis.io/commands/zinterstore
*
* @param destKey
* @param sets
*
* @param destKey must not be {@literal null}.
* @param aggregate must not be {@literal null}.
* @param weights
* @param sets must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/zinterstore">Redis Documentation: ZINTERSTORE</a>
*/
Long zInterStore(byte[] destKey, Aggregate aggregate, int[] weights, byte[]... sets);
/**
* Use a {@link Cursor} to iterate over elements in sorted set at {@code key}.
* <p>
* See http://redis.io/commands/scan
*
* @since 1.4
* @param key
* @param options
*
* @param key must not be {@literal null}.
* @param options must not be {@literal null}.
* @return
* @since 1.4
* @see <a href="http://redis.io/commands/zscan">Redis Documentation: ZSCAN</a>
*/
Cursor<Tuple> zScan(byte[] key, ScanOptions options);
/**
* Get elements where score is between {@code min} and {@code max} from sorted set.
* <p>
* See http://redis.io/commands/zrangebyscore
*
* @since 1.5
* @param key
*
* @param key must not be {@literal null}.
* @param min
* @param max
* @return
* @since 1.5
* @see <a href="http://redis.io/commands/zrangebyscore">Redis Documentation: ZRANGEBYSCORE</a>
*/
Set<byte[]> zRangeByScore(byte[] key, String min, String max);
/**
* Get elements where score is between {@code Range#min} and {@code Range#max} from sorted set.
*
* @param key
* @param range
*
* @param key must not be {@literal null}.
* @param range must not be {@literal null}.
* @return
* @since 1.6
* @see <a href="http://redis.io/commands/zrangebyscore">Redis Documentation: ZRANGEBYSCORE</a>
*/
Set<byte[]> zRangeByScore(byte[] key, Range range);
/**
* Get elements in range from {@code begin} to {@code end} where score is between {@code min} and {@code max} from
* Get elements in range from {@code start} to {@code end} where score is between {@code min} and {@code max} from
* sorted set.
* <p>
* See http://redis.io/commands/zrangebyscore
*
* @since 1.5
* @param key
* @param min
* @param max
*
* @param key must not be {@literal null}.
* @param min must not be {@literal null}.
* @param max must not be {@literal null}.
* @param offset
* @param count
* @return
* @since 1.5
* @see <a href="http://redis.io/commands/zrangebyscore">Redis Documentation: ZRANGEBYSCORE</a>
*/
Set<byte[]> zRangeByScore(byte[] key, String min, String max, long offset, long count);
/**
* Get elements in range from {@code Limit#count} to {@code Limit#offset} where score is between {@code Range#min} and
* {@code Range#max} from sorted set.
*
* @param key
* @param range
*
* @param key must not be {@literal null}.
* @param range must not be {@literal null}.
* @param limit
* @return
* @since 1.6
* @see <a href="http://redis.io/commands/zrangebyscore">Redis Documentation: ZRANGEBYSCORE</a>
*/
Set<byte[]> zRangeByScore(byte[] key, Range range, Limit limit);
/**
* Get all the elements in the sorted set at {@literal key} in lexicographical ordering.
*
*
* @param key must not be {@literal null}.
* @return
* @since 1.6
* @see <a href="http://redis.io/commands/zrangebylex">Redis Documentation: ZRANGEBYLEX</a>
*/
Set<byte[]> zRangeByLex(byte[] key);
/**
* Get all the elements in {@link Range} from the sorted set at {@literal key} in lexicographical ordering.
*
*
* @param key must not be {@literal null}.
* @param range must not be {@literal null}.
* @return
* @since 1.6
* @see <a href="http://redis.io/commands/zrangebylex">Redis Documentation: ZRANGEBYLEX</a>
*/
Set<byte[]> zRangeByLex(byte[] key, Range range);
/**
* Get all the elements in {@link Range} from the sorted set at {@literal key} in lexicographical ordering. Result is
* limited via {@link Limit}.
*
*
* @param key must not be {@literal null}.
* @param range must not be {@literal null}.
* @param range can be {@literal null}.
* @return
* @since 1.6
* @see <a href="http://redis.io/commands/zrangebylex">Redis Documentation: ZRANGEBYLEX</a>
*/
Set<byte[]> zRangeByLex(byte[] key, Range range, Limit limit);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 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.
@@ -41,7 +41,7 @@ public interface BoundGeoOperations<K, M> extends BoundKeyOperations<K> {
* @param point must not be {@literal null}.
* @param member must not be {@literal null}.
* @return Number of elements added.
* @see <a href="http://redis.io/commands/geoadd">http://redis.io/commands/geoadd</a>
* @see <a href="http://redis.io/commands/geoadd">Redis Documentation: GEOADD</a>
*/
Long geoAdd(Point point, M member);
@@ -50,7 +50,7 @@ public interface BoundGeoOperations<K, M> extends BoundKeyOperations<K> {
*
* @param location must not be {@literal null}.
* @return Number of elements added.
* @see <a href="http://redis.io/commands/geoadd">http://redis.io/commands/geoadd</a>
* @see <a href="http://redis.io/commands/geoadd">Redis Documentation: GEOADD</a>
*/
Long geoAdd(GeoLocation<M> location);
@@ -59,7 +59,7 @@ public interface BoundGeoOperations<K, M> extends BoundKeyOperations<K> {
*
* @param memberCoordinateMap must not be {@literal null}.
* @return Number of elements added.
* @see <a href="http://redis.io/commands/geoadd">http://redis.io/commands/geoadd</a>
* @see <a href="http://redis.io/commands/geoadd">Redis Documentation: GEOADD</a>
*/
Long geoAdd(Map<M, Point> memberCoordinateMap);
@@ -68,7 +68,7 @@ public interface BoundGeoOperations<K, M> extends BoundKeyOperations<K> {
*
* @param locations must not be {@literal null}.
* @return Number of elements added.
* @see <a href="http://redis.io/commands/geoadd">http://redis.io/commands/geoadd</a>
* @see <a href="http://redis.io/commands/geoadd">Redis Documentation: GEOADD</a>
*/
Long geoAdd(Iterable<GeoLocation<M>> locations);
@@ -78,7 +78,7 @@ public interface BoundGeoOperations<K, M> extends BoundKeyOperations<K> {
* @param member1 must not be {@literal null}.
* @param member2 must not be {@literal null}.
* @return can be {@literal null}.
* @see <a href="http://redis.io/commands/geodist">http://redis.io/commands/geodist</a>
* @see <a href="http://redis.io/commands/geodist">Redis Documentation: GEODIST</a>
*/
Distance geoDist(M member1, M member2);
@@ -89,7 +89,7 @@ public interface BoundGeoOperations<K, M> extends BoundKeyOperations<K> {
* @param member2 must not be {@literal null}.
* @param metric must not be {@literal null}.
* @return can be {@literal null}.
* @see <a href="http://redis.io/commands/geodist">http://redis.io/commands/geodist</a>
* @see <a href="http://redis.io/commands/geodist">Redis Documentation: GEODIST</a>
*/
Distance geoDist(M member1, M member2, Metric metric);
@@ -98,7 +98,7 @@ public interface BoundGeoOperations<K, M> extends BoundKeyOperations<K> {
*
* @param members must not be {@literal null}.
* @return never {@literal null}.
* @see <a href="http://redis.io/commands/geohash">http://redis.io/commands/geohash</a>
* @see <a href="http://redis.io/commands/geohash">Redis Documentation: GEOHASH</a>
*/
List<String> geoHash(M... members);
@@ -107,7 +107,7 @@ public interface BoundGeoOperations<K, M> extends BoundKeyOperations<K> {
*
* @param members must not be {@literal null}.
* @return never {@literal null}.
* @see <a href="http://redis.io/commands/geopos">http://redis.io/commands/geopos</a>
* @see <a href="http://redis.io/commands/geopos">Redis Documentation: GEOPOS</a>
*/
List<Point> geoPos(M... members);
@@ -116,7 +116,7 @@ public interface BoundGeoOperations<K, M> extends BoundKeyOperations<K> {
*
* @param within must not be {@literal null}.
* @return never {@literal null}.
* @see <a href="http://redis.io/commands/georadius">http://redis.io/commands/georadius</a>
* @see <a href="http://redis.io/commands/georadius">Redis Documentation: GEORADIUS</a>
*/
GeoResults<GeoLocation<M>> geoRadius(Circle within);
@@ -126,7 +126,7 @@ public interface BoundGeoOperations<K, M> extends BoundKeyOperations<K> {
* @param within must not be {@literal null}.
* @param args must not be {@literal null}.
* @return never {@literal null}.
* @see <a href="http://redis.io/commands/georadius">http://redis.io/commands/georadius</a>
* @see <a href="http://redis.io/commands/georadius">Redis Documentation: GEORADIUS</a>
*/
GeoResults<GeoLocation<M>> geoRadius(Circle within, GeoRadiusCommandArgs args);
@@ -137,7 +137,7 @@ public interface BoundGeoOperations<K, M> extends BoundKeyOperations<K> {
* @param member must not be {@literal null}.
* @param radius
* @return never {@literal null}.
* @see <a href="http://redis.io/commands/georadiusbymember">http://redis.io/commands/georadiusbymember</a>
* @see <a href="http://redis.io/commands/georadiusbymember">Redis Documentation: GEORADIUSBYMEMBER</a>
*/
GeoResults<GeoLocation<M>> geoRadiusByMember(K key, M member, double radius);
@@ -148,7 +148,7 @@ public interface BoundGeoOperations<K, M> extends BoundKeyOperations<K> {
* @param member must not be {@literal null}.
* @param distance must not be {@literal null}.
* @return never {@literal null}.
* @see <a href="http://redis.io/commands/georadiusbymember">http://redis.io/commands/georadiusbymember</a>
* @see <a href="http://redis.io/commands/georadiusbymember">Redis Documentation: GEORADIUSBYMEMBER</a>
*/
GeoResults<GeoLocation<M>> geoRadiusByMember(M member, Distance distance);
@@ -160,7 +160,7 @@ public interface BoundGeoOperations<K, M> extends BoundKeyOperations<K> {
* @param distance must not be {@literal null}.
* @param args must not be {@literal null}.
* @return never {@literal null}.
* @see <a href="http://redis.io/commands/georadiusbymember">http://redis.io/commands/georadiusbymember</a>
* @see <a href="http://redis.io/commands/georadiusbymember">Redis Documentation: GEORADIUSBYMEMBER</a>
*/
GeoResults<GeoLocation<M>> geoRadiusByMember(M member, Distance distance, GeoRadiusCommandArgs args);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2016 the original author or authors.
* Copyright 2011-2017 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.
@@ -26,16 +26,20 @@ import java.util.Set;
* @author Costin Leau
* @author Christoph Strobl
* @author Ninad Divadkar
* @author Mark Paluch
*/
public interface BoundHashOperations<H, HK, HV> extends BoundKeyOperations<H> {
/**
* Delete given hash {@code keys} at the bound key.
*
* @param keys must not be {@literal null}.
* @return
*/
RedisOperations<H, ?> getOperations();
Long delete(Object... keys);
/**
* Determine if given hash {@code key} exists.
* Determine if given hash {@code key} exists at the bound key.
*
* @param key must not be {@literal null}.
* @return
@@ -43,7 +47,23 @@ public interface BoundHashOperations<H, HK, HV> extends BoundKeyOperations<H> {
Boolean hasKey(Object key);
/**
* Increment {@code value} of a hash {@code key} by the given {@code delta}.
* Get value for given {@code key} from the hash at the bound key.
*
* @param key must not be {@literal null}.
* @return
*/
HV get(Object key);
/**
* Get values for given {@code keys} from the hash at the bound key.
*
* @param keys must not be {@literal null}.
* @return
*/
List<HV> multiGet(Collection<HK> keys);
/**
* Increment {@code value} of a hash {@code key} by the given {@code delta} at the bound key.
*
* @param key must not be {@literal null}.
* @param delta
@@ -52,7 +72,7 @@ public interface BoundHashOperations<H, HK, HV> extends BoundKeyOperations<H> {
Long increment(HK key, long delta);
/**
* Increment {@code value} of a hash {@code key} by the given {@code delta}.
* Increment {@code value} of a hash {@code key} by the given {@code delta} at the bound key.
*
* @param key must not be {@literal null}.
* @param delta
@@ -61,15 +81,28 @@ public interface BoundHashOperations<H, HK, HV> extends BoundKeyOperations<H> {
Double increment(HK key, double delta);
/**
* Get value for given {@code key} from the hash.
* Get key set (fields) of hash at the bound key.
*
* @param key must not be {@literal null}.
* @return
*/
HV get(Object key);
Set<HK> keys();
/**
* Set the {@code value} of a hash {@code key}.
* Get size of hash at the bound key.
*
* @return
*/
Long size();
/**
* Set multiple hash fields to multiple values using data provided in {@code m} at the bound key.
*
* @param m must not be {@literal null}.
*/
void putAll(Map<? extends HK, ? extends HV> m);
/**
* Set the {@code value} of a hash {@code key} at the bound key.
*
* @param key must not be {@literal null}.
* @param value
@@ -86,51 +119,14 @@ public interface BoundHashOperations<H, HK, HV> extends BoundKeyOperations<H> {
Boolean putIfAbsent(HK key, HV value);
/**
* Get values for given {@code keys} from the hash.
*
* @param keys must not be {@literal null}.
* @return
*/
List<HV> multiGet(Collection<HK> keys);
/**
* Set multiple hash fields to multiple values using data provided in {@code m}.
*
* @param m must not be {@literal null}.
*/
void putAll(Map<? extends HK, ? extends HV> m);
/**
* Get key set (fields) of the hash.
*
* @return
*/
Set<HK> keys();
/**
* Get entry set (values) of hash.
* Get entry set (values) of hash at the bound key.
*
* @return
*/
List<HV> values();
/**
* Get size of the hash.
*
* @return
*/
Long size();
/**
* Delete given hash {@code keys}.
*
* @param keys must not be {@literal null}.
* @return
*/
Long delete(Object... keys);
/**
* Get entire hash.
* Get entire hash at the bound key.
*
* @return
*/
@@ -144,4 +140,9 @@ public interface BoundHashOperations<H, HK, HV> extends BoundKeyOperations<H> {
* @since 1.4
*/
Cursor<Map.Entry<HK, HV>> scan(ScanOptions options);
/**
* @return
*/
RedisOperations<H, ?> getOperations();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2014 the original author or authors.
* Copyright 2011-2017 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.
@@ -24,11 +24,12 @@ import org.springframework.data.redis.connection.DataType;
* Operations over a Redis key. Useful for executing common key-'bound' operations to all implementations.
* <p>
* As the rest of the APIs, if the underlying connection is pipelined or queued/in multi mode, all methods will return
* null.
* {@literal null}.
* <p>
*
* @author Costin Leau
* @author Christoph Strobl
* @author Mark Paluch
*/
public interface BoundKeyOperations<K> {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2013 the original author or authors.
* Copyright 2011-2017 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.
@@ -22,44 +22,174 @@ import java.util.concurrent.TimeUnit;
* List operations bound to a certain key.
*
* @author Costin Leau
* @author Mark Paluch
*/
public interface BoundListOperations<K, V> extends BoundKeyOperations<K> {
RedisOperations<K, V> getOperations();
/**
* Get elements between {@code begin} and {@code end} from list at the bound key.
*
* @param start
* @param end
* @return
* @see <a href="http://redis.io/commands/lrange">Redis Documentation: LRANGE</a>
*/
List<V> range(long start, long end);
/**
* Trim list at the bound key to elements between {@code start} and {@code end}.
*
* @param start
* @param end
* @see <a href="http://redis.io/commands/ltrim">Redis Documentation: LTRIM</a>
*/
void trim(long start, long end);
/**
* Get the size of list stored at the bound key.
*
* @return
* @see <a href="http://redis.io/commands/llen">Redis Documentation: LLEN</a>
*/
Long size();
/**
* Prepend {@code value} to the bound key.
*
* @param value
* @return
* @see <a href="http://redis.io/commands/lpush">Redis Documentation: LPUSH</a>
*/
Long leftPush(V value);
/**
* Prepend {@code values} to the bound key.
*
* @param values
* @return
* @see <a href="http://redis.io/commands/lpush">Redis Documentation: LPUSH</a>
*/
Long leftPushAll(V... values);
/**
* Prepend {@code values} to the bound key only if the list exists.
*
* @param value
* @return
* @see <a href="http://redis.io/commands/lpushx">Redis Documentation: LPUSHX</a>
*/
Long leftPushIfPresent(V value);
/**
* Prepend {@code values} to the bound key before {@code value}.
*
* @param value
* @return
* @see <a href="http://redis.io/commands/lpush">Redis Documentation: LPUSH</a>
*/
Long leftPush(V pivot, V value);
/**
* Append {@code value} to the bound key.
*
* @param value
* @return
* @see <a href="http://redis.io/commands/rpush">Redis Documentation: RPUSH</a>
*/
Long rightPush(V value);
/**
* Append {@code values} to the bound key.
*
* @param values
* @return
* @see <a href="http://redis.io/commands/rpush">Redis Documentation: RPUSH</a>
*/
Long rightPushAll(V... values);
/**
* Append {@code values} to the bound key only if the list exists.
*
* @param value
* @return
* @see <a href="http://redis.io/commands/rpushx">Redis Documentation: RPUSHX</a>
*/
Long rightPushIfPresent(V value);
/**
* Append {@code values} to the bound key before {@code value}.
*
* @param value
* @return
* @see <a href="http://redis.io/commands/lpush">Redis Documentation: RPUSH</a>
*/
Long rightPush(V pivot, V value);
V leftPop();
/**
* Set the {@code value} list element at {@code index}.
*
* @param index
* @param value
* @see <a href="http://redis.io/commands/lset">Redis Documentation: LSET</a>
*/
void set(long index, V value);
V leftPop(long timeout, TimeUnit unit);
V rightPop();
V rightPop(long timeout, TimeUnit unit);
Long remove(long i, Object value);
/**
* Removes the first {@code count} occurrences of {@code value} from the list stored at the bound key.
*
* @param count
* @param value
* @return
* @see <a href="http://redis.io/commands/lrem">Redis Documentation: LREM</a>
*/
Long remove(long count, Object value);
/**
* Get element at {@code index} form list at the bound key.
*
* @param index
* @return
* @see <a href="http://redis.io/commands/lindex">Redis Documentation: LINDEX</a>
*/
V index(long index);
void set(long index, V value);
/**
* Removes and returns first element in list stored at the bound key.
*
* @return
* @see <a href="http://redis.io/commands/lpop">Redis Documentation: LPOP</a>
*/
V leftPop();
/**
* Removes and returns first element from lists stored at the bound key . <br>
* <b>Blocks connection</b> until element available or {@code timeout} reached.
*
* @param timeout
* @param unit must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/blpop">Redis Documentation: BLPOP</a>
*/
V leftPop(long timeout, TimeUnit unit);
/**
* Removes and returns last element in list stored at the bound key.
*
* @return
* @see <a href="http://redis.io/commands/rpop">Redis Documentation: RPOP</a>
*/
V rightPop();
/**
* Removes and returns last element from lists stored at the bound key. <br>
* <b>Blocks connection</b> until element available or {@code timeout} reached.
*
* @param timeout
* @param unit must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/brpop">Redis Documentation: BRPOP</a>
*/
V rightPop(long timeout, TimeUnit unit);
RedisOperations<K, V> getOperations();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2013 the original author or authors.
* Copyright 2011-2017 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.
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.redis.core;
import java.util.Collection;
@@ -24,59 +23,218 @@ import java.util.Set;
* Set operations bound to a certain key.
*
* @author Costin Leau
* @author Mark Paluch
*/
public interface BoundSetOperations<K, V> extends BoundKeyOperations<K> {
RedisOperations<K, V> getOperations();
Set<V> diff(K key);
Set<V> diff(Collection<K> keys);
void diffAndStore(K key, K destKey);
void diffAndStore(Collection<K> keys, K destKey);
Set<V> intersect(K key);
Set<V> intersect(Collection<K> keys);
void intersectAndStore(K key, K destKey);
void intersectAndStore(Collection<K> keys, K destKey);
Set<V> union(K key);
Set<V> union(Collection<K> keys);
void unionAndStore(K key, K destKey);
void unionAndStore(Collection<K> keys, K destKey);
/**
* Add given {@code values} to set at the bound key.
*
* @param values
* @return
* @see <a href="http://redis.io/commands/sadd">Redis Documentation: SADD</a>
*/
Long add(V... values);
Boolean isMember(Object o);
Set<V> members();
Boolean move(K destKey, V value);
V randomMember();
Set<V> distinctRandomMembers(long count);
List<V> randomMembers(long count);
/**
* Remove given {@code values} from set at the bound key and return the number of removed elements.
*
* @param values
* @return
* @see <a href="http://redis.io/commands/srem">Redis Documentation: SREM</a>
*/
Long remove(Object... values);
/**
* Remove and return a random member from set at the bound key.
*
* @return
* @see <a href="http://redis.io/commands/spop">Redis Documentation: SPOP</a>
*/
V pop();
/**
* Move {@code value} from the bound key to {@code destKey}
*
* @param destKey must not be {@literal null}.
* @param value
* @return
* @see <a href="http://redis.io/commands/smove">Redis Documentation: SMOVE</a>
*/
Boolean move(K destKey, V value);
/**
* Get size of set at the bound key.
*
* @return
* @see <a href="http://redis.io/commands/scard">Redis Documentation: SCARD</a>
*/
Long size();
/**
* Check if set at the bound key contains {@code value}.
*
* @param o
* @return
* @see <a href="http://redis.io/commands/sismember">Redis Documentation: SISMEMBER</a>
*/
Boolean isMember(Object o);
/**
* Returns the members intersecting all given sets at the bound key and {@code key}.
*
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/sinter">Redis Documentation: SINTER</a>
*/
Set<V> intersect(K key);
/**
* Returns the members intersecting all given sets at the bound key and {@code keys}.
*
* @param keys must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/sinter">Redis Documentation: SINTER</a>
*/
Set<V> intersect(Collection<K> keys);
/**
* Intersect all given sets at the bound key and {@code key} and store result in {@code destKey}.
*
* @param key must not be {@literal null}.
* @param destKey must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/sinterstore">Redis Documentation: SINTERSTORE</a>
*/
void intersectAndStore(K key, K destKey);
/**
* Intersect all given sets at the bound key and {@code keys} and store result in {@code destKey}.
*
* @param keys must not be {@literal null}.
* @param destKey must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/sinterstore">Redis Documentation: SINTERSTORE</a>
*/
void intersectAndStore(Collection<K> keys, K destKey);
/**
* Union all sets at given {@code key} and {@code key}.
*
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/sunion">Redis Documentation: SUNION</a>
*/
Set<V> union(K key);
/**
* Union all sets at given {@code keys} and {@code keys}.
*
* @param keys must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/sunion">Redis Documentation: SUNION</a>
*/
Set<V> union(Collection<K> keys);
/**
* Union all sets at given the bound key and {@code key} and store result in {@code destKey}.
*
* @param key must not be {@literal null}.
* @param destKey must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/sunionstore">Redis Documentation: SUNIONSTORE</a>
*/
void unionAndStore(K key, K destKey);
/**
* Union all sets at given the bound key and {@code keys} and store result in {@code destKey}.
*
* @param keys must not be {@literal null}.
* @param destKey must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/sunionstore">Redis Documentation: SUNIONSTORE</a>
*/
void unionAndStore(Collection<K> keys, K destKey);
/**
* Diff all sets for given the bound key and {@code key}.
*
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/sdiff">Redis Documentation: SDIFF</a>
*/
Set<V> diff(K key);
/**
* Diff all sets for given the bound key and {@code keys}.
*
* @param keys must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/sdiff">Redis Documentation: SDIFF</a>
*/
Set<V> diff(Collection<K> keys);
/**
* Diff all sets for given the bound key and {@code keys} and store result in {@code destKey}.
*
* @param keys must not be {@literal null}.
* @param destKey must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/sdiffstore">Redis Documentation: SDIFFSTORE</a>
*/
void diffAndStore(K keys, K destKey);
/**
* Diff all sets for given the bound key and {@code keys} and store result in {@code destKey}.
*
* @param keys must not be {@literal null}.
* @param destKey must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/sdiffstore">Redis Documentation: SDIFFSTORE</a>
*/
void diffAndStore(Collection<K> keys, K destKey);
/**
* Get all elements of set at the bound key.
*
* @return
* @see <a href="http://redis.io/commands/smembers">Redis Documentation: SMEMBERS</a>
*/
Set<V> members();
/**
* Get random element from set at the bound key.
*
* @return
* @see <a href="http://redis.io/commands/srandmember">Redis Documentation: SRANDMEMBER</a>
*/
V randomMember();
/**
* Get {@code count} distinct random elements from set at the bound key.
*
* @param count
* @return
* @see <a href="http://redis.io/commands/srandmember">Redis Documentation: SRANDMEMBER</a>
*/
Set<V> distinctRandomMembers(long count);
/**
* Get {@code count} random elements from set at the bound key.
*
* @param count
* @return
* @see <a href="http://redis.io/commands/srandmember">Redis Documentation: SRANDMEMBER</a>
*/
List<V> randomMembers(long count);
/**
* @param options
* @return
* @since 1.4
*/
Cursor<V> scan(ScanOptions options);
RedisOperations<K, V> getOperations();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2013 the original author or authors.
* Copyright 2011-2017 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.
@@ -21,30 +21,98 @@ import java.util.concurrent.TimeUnit;
* Value (or String in Redis terminology) operations bound to a certain key.
*
* @author Costin Leau
* @author Mark Paluch
*/
public interface BoundValueOperations<K, V> extends BoundKeyOperations<K> {
RedisOperations<K, V> getOperations();
/**
* Set {@code value} for the bound key.
*
* @param value
* @see <a href="http://redis.io/commands/set">Redis Documentation: SET</a>
*/
void set(V value);
void set(V value, long offset);
/**
* Set the {@code value} and expiration {@code timeout} for the bound key.
*
* @param value
* @param timeout
* @param unit must not be {@literal null}.
* @see <a href="http://redis.io/commands/setex">Redis Documentation: SETEX</a>
*/
void set(V value, long timeout, TimeUnit unit);
/**
* Set the bound key to hold the string {@code value} if the bound key is absent.
*
* @param value
* @see <a href="http://redis.io/commands/setnx">Redis Documentation: SETNX</a>
*/
Boolean setIfAbsent(V value);
/**
* Get the value of the bound key.
*
* @see <a href="http://redis.io/commands/get">Redis Documentation: GET</a>
*/
V get();
String get(long start, long end);
/**
* Set {@code value} of the bound key and return its old value.
*
* @see <a href="http://redis.io/commands/getset">Redis Documentation: GETSET</a>
*/
V getAndSet(V value);
/**
* Increment an integer value stored as string value under the bound key by {@code delta}.
*
* @param delta
* @see <a href="http://redis.io/commands/incr">Redis Documentation: INCR</a>
*/
Long increment(long delta);
/**
* Increment a floating point number value stored as string value under the bound key by {@code delta}.
*
* @param delta
* @see <a href="http://redis.io/commands/incrbyfloar">Redis Documentation: INCRBYFLOAT</a>
*/
Double increment(double delta);
/**
* Append a {@code value} to the bound key.
*
* @param value
* @see <a href="http://redis.io/commands/append">Redis Documentation: APPEND</a>
*/
Integer append(String value);
/**
* Get a substring of value of the bound key between {@code begin} and {@code end}.
*
* @param start
* @param end
* @see <a href="http://redis.io/commands/getrange">Redis Documentation: GETRANGE</a>
*/
String get(long start, long end);
/**
* Overwrite parts of the bound key starting at the specified {@code offset} with given {@code value}.
*
* @param value
* @param offset
* @see <a href="http://redis.io/commands/setrange">Redis Documentation: SETRANGE</a>
*/
void set(V value, long offset);
/**
* Get the length of the value stored at the bound key.
*
* @see <a href="http://redis.io/commands/strlen">Redis Documentation: STRLEN</a>
*/
Long size();
RedisOperations<K, V> getOperations();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2016 the original author or authors.
* Copyright 2011-2017 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.
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.redis.core;
import java.util.Collection;
@@ -21,6 +20,7 @@ import java.util.Set;
import org.springframework.data.redis.connection.RedisZSetCommands.Limit;
import org.springframework.data.redis.connection.RedisZSetCommands.Range;
import org.springframework.data.redis.connection.RedisZSetCommands.Tuple;
import org.springframework.data.redis.core.ZSetOperations.TypedTuple;
/**
@@ -32,34 +32,257 @@ import org.springframework.data.redis.core.ZSetOperations.TypedTuple;
*/
public interface BoundZSetOperations<K, V> extends BoundKeyOperations<K> {
RedisOperations<K, V> getOperations();
/**
* Add {@code value} to a sorted set at the bound key, or update its {@code score} if it already exists.
*
* @param score the score.
* @param value the value.
* @return
* @see <a href="http://redis.io/commands/zadd">Redis Documentation: ZADD</a>
*/
Boolean add(V value, double score);
void intersectAndStore(K otherKey, K destKey);
/**
* Add {@code tuples} to a sorted set at the bound key, or update its {@code score} if it already exists.
*
* @param tuples must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/zadd">Redis Documentation: ZADD</a>
*/
Long add(Set<TypedTuple<V>> tuples);
void intersectAndStore(Collection<K> otherKeys, K destKey);
/**
* Remove {@code values} from sorted set. Return number of removed elements.
*
* @param values must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/zrem">Redis Documentation: ZREM</a>
*/
Long remove(Object... values);
/**
* Increment the score of element with {@code value} in sorted set by {@code increment}.
*
* @param delta
* @param value the value.
* @return
* @see <a href="http://redis.io/commands/zincrby">Redis Documentation: ZINCRBY</a>
*/
Double incrementScore(V value, double delta);
/**
* Determine the index of element with {@code value} in a sorted set.
*
* @param o the value.
* @return
* @see <a href="http://redis.io/commands/zrank">Redis Documentation: ZRANK</a>
*/
Long rank(Object o);
/**
* Determine the index of element with {@code value} in a sorted set when scored high to low.
*
* @param o the value.
* @return
* @see <a href="http://redis.io/commands/zrevrank">Redis Documentation: ZREVRANK</a>
*/
Long reverseRank(Object o);
/**
* Get elements between {@code start} and {@code end} from sorted set.
*
* @param start
* @param end
* @return
* @see <a href="http://redis.io/commands/zrange">Redis Documentation: ZRANGE</a>
*/
Set<V> range(long start, long end);
Set<V> rangeByScore(double min, double max);
Set<V> reverseRange(long start, long end);
Set<V> reverseRangeByScore(double min, double max);
/**
* Get set of {@link Tuple}s between {@code start} and {@code end} from sorted set.
*
* @param start
* @param end
* @return
* @see <a href="http://redis.io/commands/zrange">Redis Documentation: ZRANGE</a>
*/
Set<TypedTuple<V>> rangeWithScores(long start, long end);
/**
* Get elements where score is between {@code min} and {@code max} from sorted set.
*
* @param min
* @param max
* @return
* @see <a href="http://redis.io/commands/zrangebyscore">Redis Documentation: ZRANGEBYSCORE</a>
*/
Set<V> rangeByScore(double min, double max);
/**
* Get set of {@link Tuple}s where score is between {@code min} and {@code max} from sorted set.
*
* @param min
* @param max
* @return
* @see <a href="http://redis.io/commands/zrangebyscore">Redis Documentation: ZRANGEBYSCORE</a>
*/
Set<TypedTuple<V>> rangeByScoreWithScores(double min, double max);
/**
* Get elements in range from {@code start} to {@code end} from sorted set ordered from high to low.
*
* @param start
* @param end
* @return
* @see <a href="http://redis.io/commands/zrevrange">Redis Documentation: ZREVRANGE</a>
*/
Set<V> reverseRange(long start, long end);
/**
* Get set of {@link Tuple}s in range from {@code start} to {@code end} from sorted set ordered from high to low.
*
* @param start
* @param end
* @return
* @see <a href="http://redis.io/commands/zrevrange">Redis Documentation: ZREVRANGE</a>
*/
Set<TypedTuple<V>> reverseRangeWithScores(long start, long end);
/**
* Get elements where score is between {@code min} and {@code max} from sorted set ordered from high to low.
*
* @param min
* @param max
* @return
* @see <a href="http://redis.io/commands/zrevrange">Redis Documentation: ZREVRANGE</a>
*/
Set<V> reverseRangeByScore(double min, double max);
/**
* Get set of {@link Tuple} where score is between {@code min} and {@code max} from sorted set ordered from high to
* low.
*
* @param min
* @param max
* @return
* @see <a href="http://redis.io/commands/zrevrangebyscore">Redis Documentation: ZREVRANGEBYSCORE</a>
*/
Set<TypedTuple<V>> reverseRangeByScoreWithScores(double min, double max);
/**
* Count number of elements within sorted set with scores between {@code min} and {@code max}.
*
* @param min
* @param max
* @return
* @see <a href="http://redis.io/commands/zcount">Redis Documentation: ZCOUNT</a>
*/
Long count(double min, double max);
/**
* Returns the number of elements of the sorted set stored with given the bound key.
*
* @see #zCard()
* @return
* @see <a href="http://redis.io/commands/zcard">Redis Documentation: ZCARD</a>
*/
Long size();
/**
* Get the size of sorted set with the bound key.
*
* @return
* @since 1.3
* @see <a href="http://redis.io/commands/zcard">Redis Documentation: ZCARD</a>
*/
Long zCard();
/**
* Get the score of element with {@code value} from sorted set with key the bound key.
*
* @param o the value.
* @return
* @see <a href="http://redis.io/commands/zrem">Redis Documentation: ZREM</a>
*/
Double score(Object o);
/**
* Remove elements in range between {@code start} and {@code end} from sorted set with the bound key.
*
* @param start
* @param end
* @return
* @see <a href="http://redis.io/commands/zremrangebyrank">Redis Documentation: ZREMRANGEBYRANK</a>
*/
void removeRange(long start, long end);
/**
* Remove elements with scores between {@code min} and {@code max} from sorted set with the bound key.
*
* @param min
* @param max
* @return
* @see <a href="http://redis.io/commands/zremrangebyscore">Redis Documentation: ZREMRANGEBYSCORE</a>
*/
void removeRangeByScore(double min, double max);
/**
* Union sorted sets at the bound key and {@code otherKeys} and store result in destination {@code destKey}.
*
* @param otherKey must not be {@literal null}.
* @param destKey must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/zunionstore">Redis Documentation: ZUNIONSTORE</a>
*/
void unionAndStore(K otherKey, K destKey);
/**
* Union sorted sets at the bound key and {@code otherKeys} and store result in destination {@code destKey}.
*
* @param otherKeys must not be {@literal null}.
* @param destKey must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/zunionstore">Redis Documentation: ZUNIONSTORE</a>
*/
void unionAndStore(Collection<K> otherKeys, K destKey);
/**
* Intersect sorted sets at the bound key and {@code otherKey} and store result in destination {@code destKey}.
*
* @param otherKey must not be {@literal null}.
* @param destKey must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/zinterstore">Redis Documentation: ZINTERSTORE</a>
*/
void intersectAndStore(K otherKey, K destKey);
/**
* Intersect sorted sets at the bound key and {@code otherKeys} and store result in destination {@code destKey}.
*
* @param otherKeys must not be {@literal null}.
* @param destKey must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/zinterstore">Redis Documentation: ZINTERSTORE</a>
*/
void intersectAndStore(Collection<K> otherKeys, K destKey);
/**
* Iterate over elements in zset at the bound key. <br />
* <strong>Important:</strong> Call {@link Cursor#close()} when done to avoid resource leak.
*
* @param options
* @return
* @since 1.4
*/
Cursor<TypedTuple<V>> scan(ScanOptions options);
/**
* Get all elements with lexicographical ordering with a value between {@link Range#getMin()} and
* {@link Range#getMax()}.
*
*
* @param range must not be {@literal null}.
* @since 1.7
* @see <a href="http://redis.io/commands/zrangebylex">Redis Documentation: ZRANGEBYLEX</a>
*/
Set<V> rangeByLex(Range range);
@@ -67,58 +290,14 @@ public interface BoundZSetOperations<K, V> extends BoundKeyOperations<K> {
* Get all elements {@literal n} elements, where {@literal n = } {@link Limit#getCount()}, starting at
* {@link Limit#getOffset()} with lexicographical ordering having a value between {@link Range#getMin()} and
* {@link Range#getMax()}.
*
*
* @param range must not be {@literal null}.
* @param limit can be {@literal null}.
* @return
* @since 1.7
* @see <a href="http://redis.io/commands/zrangebylex">Redis Documentation: ZRANGEBYLEX</a>
*/
Set<V> rangeByLex(Range range, Limit limit);
void removeRange(long start, long end);
void removeRangeByScore(double min, double max);
void unionAndStore(K otherKey, K destKey);
void unionAndStore(Collection<K> otherKeys, K destKey);
Boolean add(V value, double score);
Long add(Set<TypedTuple<V>> tuples);
Double incrementScore(V value, double delta);
Long rank(Object o);
Long reverseRank(Object o);
Long remove(Object... values);
Long count(double min, double max);
/**
* Returns the number of elements of the sorted set.
*
* @return
* @see #zCard()
*/
Long size();
/**
* Returns the number of elements of the sorted set.
*
* @return
* @since 1.3
*/
Long zCard();
Double score(Object o);
/**
* @param options
* @return
* @since 1.4
*/
Cursor<TypedTuple<V>> scan(ScanOptions options);
RedisOperations<K, V> getOperations();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 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.
@@ -31,7 +31,8 @@ import org.springframework.data.redis.connection.RedisGeoCommands.GeoRadiusComma
*
* @author Ninad Divadkar
* @author Christoph Strobl
* @see <a href="http://redis.io/commands#geo">http://redis.io/commands#geo</a>
* @author Mark Paluch
* @see <a href="http://redis.io/commands#geo">Redis Documentation: Geo Commands</a>
* @since 1.8
*/
public interface GeoOperations<K, M> {
@@ -43,7 +44,7 @@ public interface GeoOperations<K, M> {
* @param point must not be {@literal null}.
* @param member must not be {@literal null}.
* @return Number of elements added.
* @see <a href="http://redis.io/commands/geoadd">http://redis.io/commands/geoadd</a>
* @see <a href="http://redis.io/commands/geoadd">Redis Documentation: GEOADD</a>
*/
Long geoAdd(K key, Point point, M member);
@@ -53,7 +54,7 @@ public interface GeoOperations<K, M> {
* @param key must not be {@literal null}.
* @param location must not be {@literal null}.
* @return Number of elements added.
* @see <a href="http://redis.io/commands/geoadd">http://redis.io/commands/geoadd</a>
* @see <a href="http://redis.io/commands/geoadd">Redis Documentation: GEOADD</a>
*/
Long geoAdd(K key, GeoLocation<M> location);
@@ -63,7 +64,7 @@ public interface GeoOperations<K, M> {
* @param key must not be {@literal null}.
* @param memberCoordinateMap must not be {@literal null}.
* @return Number of elements added.
* @see <a href="http://redis.io/commands/geoadd">http://redis.io/commands/geoadd</a>
* @see <a href="http://redis.io/commands/geoadd">Redis Documentation: GEOADD</a>
*/
Long geoAdd(K key, Map<M, Point> memberCoordinateMap);
@@ -73,7 +74,7 @@ public interface GeoOperations<K, M> {
* @param key must not be {@literal null}.
* @param locations must not be {@literal null}.
* @return Number of elements added.
* @see <a href="http://redis.io/commands/geoadd">http://redis.io/commands/geoadd</a>
* @see <a href="http://redis.io/commands/geoadd">Redis Documentation: GEOADD</a>
*/
Long geoAdd(K key, Iterable<GeoLocation<M>> locations);
@@ -84,7 +85,7 @@ public interface GeoOperations<K, M> {
* @param member1 must not be {@literal null}.
* @param member2 must not be {@literal null}.
* @return can be {@literal null}.
* @see <a href="http://redis.io/commands/geodist">http://redis.io/commands/geodist</a>
* @see <a href="http://redis.io/commands/geodist">Redis Documentation: GEODIST</a>
*/
Distance geoDist(K key, M member1, M member2);
@@ -96,7 +97,7 @@ public interface GeoOperations<K, M> {
* @param member2 must not be {@literal null}.
* @param metric must not be {@literal null}.
* @return can be {@literal null}.
* @see <a href="http://redis.io/commands/geodist">http://redis.io/commands/geodist</a>
* @see <a href="http://redis.io/commands/geodist">Redis Documentation: GEODIST</a>
*/
Distance geoDist(K key, M member1, M member2, Metric metric);
@@ -106,7 +107,7 @@ public interface GeoOperations<K, M> {
* @param key must not be {@literal null}.
* @param members must not be {@literal null}.
* @return never {@literal null}.
* @see <a href="http://redis.io/commands/geohash">http://redis.io/commands/geohash</a>
* @see <a href="http://redis.io/commands/geohash">Redis Documentation: GEOHASH</a>
*/
List<String> geoHash(K key, M... members);
@@ -116,7 +117,7 @@ public interface GeoOperations<K, M> {
* @param key must not be {@literal null}.
* @param members must not be {@literal null}.
* @return never {@literal null}.
* @see <a href="http://redis.io/commands/geopos">http://redis.io/commands/geopos</a>
* @see <a href="http://redis.io/commands/geopos">Redis Documentation: GEOPOS</a>
*/
List<Point> geoPos(K key, M... members);
@@ -126,7 +127,7 @@ public interface GeoOperations<K, M> {
* @param key must not be {@literal null}.
* @param within must not be {@literal null}.
* @return never {@literal null}.
* @see <a href="http://redis.io/commands/georadius">http://redis.io/commands/georadius</a>
* @see <a href="http://redis.io/commands/georadius">Redis Documentation: GEORADIUS</a>
*/
GeoResults<GeoLocation<M>> geoRadius(K key, Circle within);
@@ -137,7 +138,7 @@ public interface GeoOperations<K, M> {
* @param within must not be {@literal null}.
* @param args must not be {@literal null}.
* @return never {@literal null}.
* @see <a href="http://redis.io/commands/georadius">http://redis.io/commands/georadius</a>
* @see <a href="http://redis.io/commands/georadius">Redis Documentation: GEORADIUS</a>
*/
GeoResults<GeoLocation<M>> geoRadius(K key, Circle within, GeoRadiusCommandArgs args);
@@ -149,7 +150,7 @@ public interface GeoOperations<K, M> {
* @param member must not be {@literal null}.
* @param radius
* @return never {@literal null}.
* @see <a href="http://redis.io/commands/georadiusbymember">http://redis.io/commands/georadiusbymember</a>
* @see <a href="http://redis.io/commands/georadiusbymember">Redis Documentation: GEORADIUSBYMEMBER</a>
*/
GeoResults<GeoLocation<M>> geoRadiusByMember(K key, M member, double radius);
@@ -161,7 +162,7 @@ public interface GeoOperations<K, M> {
* @param member must not be {@literal null}.
* @param distance must not be {@literal null}.
* @return never {@literal null}.
* @see <a href="http://redis.io/commands/georadiusbymember">http://redis.io/commands/georadiusbymember</a>
* @see <a href="http://redis.io/commands/georadiusbymember">Redis Documentation: GEORADIUSBYMEMBER</a>
*/
GeoResults<GeoLocation<M>> geoRadiusByMember(K key, M member, Distance distance);
@@ -174,7 +175,7 @@ public interface GeoOperations<K, M> {
* @param distance must not be {@literal null}.
* @param args must not be {@literal null}.
* @return never {@literal null}.
* @see <a href="http://redis.io/commands/georadiusbymember">http://redis.io/commands/georadiusbymember</a>
* @see <a href="http://redis.io/commands/georadiusbymember">Redis Documentation: GEORADIUSBYMEMBER</a>
*/
GeoResults<GeoLocation<M>> geoRadiusByMember(K key, M member, Distance distance, GeoRadiusCommandArgs args);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2016 the original author or authors.
* Copyright 2011-2017 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.
@@ -144,19 +144,19 @@ public interface HashOperations<H, HK, HV> {
*/
Map<HK, HV> entries(H key);
/**
* @return
*/
RedisOperations<H, ?> getOperations();
/**
* Use a {@link Cursor} to iterate over entries in hash at {@code key}. <br />
* <strong>Important:</strong> Call {@link Cursor#close()} when done to avoid resource leak.
*
* @since 1.4
* @param key must not be {@literal null}.
* @param options
* @return
* @since 1.4
*/
Cursor<Map.Entry<HK, HV>> scan(H key, ScanOptions options);
/**
* @return
*/
RedisOperations<H, ?> getOperations();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2014 the original author or authors.
* Copyright 2011-2017 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.
@@ -26,67 +26,236 @@ import java.util.concurrent.TimeUnit;
* @author David Liu
* @author Thomas Darimont
* @author Christoph Strobl
* @author Mark Paluch
*/
public interface ListOperations<K, V> {
/**
* Get elements between {@code begin} and {@code end} from list at {@code key}.
*
* @param key must not be {@literal null}.
* @param start
* @param end
* @return
* @see <a href="http://redis.io/commands/lrange">Redis Documentation: LRANGE</a>
*/
List<V> range(K key, long start, long end);
/**
* Trim list at {@code key} to elements between {@code start} and {@code end}.
*
* @param key must not be {@literal null}.
* @param start
* @param end
* @see <a href="http://redis.io/commands/ltrim">Redis Documentation: LTRIM</a>
*/
void trim(K key, long start, long end);
/**
* Get the size of list stored at {@code key}.
*
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/llen">Redis Documentation: LLEN</a>
*/
Long size(K key);
/**
* Prepend {@code value} to {@code key}.
*
* @param key must not be {@literal null}.
* @param value
* @return
* @see <a href="http://redis.io/commands/lpush">Redis Documentation: LPUSH</a>
*/
Long leftPush(K key, V value);
/**
* Prepend {@code values} to {@code key}.
*
* @param key must not be {@literal null}.
* @param values
* @return
* @see <a href="http://redis.io/commands/lpush">Redis Documentation: LPUSH</a>
*/
Long leftPushAll(K key, V... values);
/**
* Insert all {@literal values} at the head of the list stored at {@literal key}.
*
* Prepend {@code values} to {@code key}.
*
* @param key must not be {@literal null}.
* @param values must not be {@literal empty} nor contain {@literal null} values.
* @param values must not be {@literal null}.
* @return
* @since 1.5
* @see <a href="http://redis.io/commands/lpush">Redis Documentation: LPUSH</a>
*/
Long leftPushAll(K key, Collection<V> values);
/**
* Prepend {@code values} to {@code key} only if the list exists.
*
* @param key must not be {@literal null}.
* @param value
* @return
* @see <a href="http://redis.io/commands/lpushx">Redis Documentation: LPUSHX</a>
*/
Long leftPushIfPresent(K key, V value);
/**
* Prepend {@code values} to {@code key} before {@code value}.
*
* @param key must not be {@literal null}.
* @param value
* @return
* @see <a href="http://redis.io/commands/lpush">Redis Documentation: LPUSH</a>
*/
Long leftPush(K key, V pivot, V value);
/**
* Append {@code value} to {@code key}.
*
* @param key must not be {@literal null}.
* @param value
* @return
* @see <a href="http://redis.io/commands/rpush">Redis Documentation: RPUSH</a>
*/
Long rightPush(K key, V value);
/**
* Append {@code values} to {@code key}.
*
* @param key must not be {@literal null}.
* @param values
* @return
* @see <a href="http://redis.io/commands/rpush">Redis Documentation: RPUSH</a>
*/
Long rightPushAll(K key, V... values);
/**
* Insert all {@literal values} at the tail of the list stored at {@literal key}.
*
* Append {@code values} to {@code key}.
*
* @param key must not be {@literal null}.
* @param values must not be {@literal empty} nor contain {@literal null} values.
* @param values
* @return
* @since 1.5
* @see <a href="http://redis.io/commands/rpush">Redis Documentation: RPUSH</a>
*/
Long rightPushAll(K key, Collection<V> values);
/**
* Append {@code values} to {@code key} only if the list exists.
*
* @param key must not be {@literal null}.
* @param value
* @return
* @see <a href="http://redis.io/commands/rpushx">Redis Documentation: RPUSHX</a>
*/
Long rightPushIfPresent(K key, V value);
/**
* Append {@code values} to {@code key} before {@code value}.
*
* @param key must not be {@literal null}.
* @param value
* @return
* @see <a href="http://redis.io/commands/lpush">Redis Documentation: RPUSH</a>
*/
Long rightPush(K key, V pivot, V value);
/**
* Set the {@code value} list element at {@code index}.
*
* @param key must not be {@literal null}.
* @param index
* @param value
* @see <a href="http://redis.io/commands/lset">Redis Documentation: LSET</a>
*/
void set(K key, long index, V value);
Long remove(K key, long i, Object value);
/**
* Removes the first {@code count} occurrences of {@code value} from the list stored at {@code key}.
*
* @param key must not be {@literal null}.
* @param count
* @param value
* @return
* @see <a href="http://redis.io/commands/lrem">Redis Documentation: LREM</a>
*/
Long remove(K key, long count, Object value);
/**
* Get element at {@code index} form list at {@code key}.
*
* @param key must not be {@literal null}.
* @param index
* @return
* @see <a href="http://redis.io/commands/lindex">Redis Documentation: LINDEX</a>
*/
V index(K key, long index);
/**
* Removes and returns first element in list stored at {@code key}.
*
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/lpop">Redis Documentation: LPOP</a>
*/
V leftPop(K key);
/**
* Removes and returns first element from lists stored at {@code key} . <br>
* <b>Blocks connection</b> until element available or {@code timeout} reached.
*
* @param key must not be {@literal null}.
* @param timeout
* @param unit must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/blpop">Redis Documentation: BLPOP</a>
*/
V leftPop(K key, long timeout, TimeUnit unit);
/**
* Removes and returns last element in list stored at {@code key}.
*
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/rpop">Redis Documentation: RPOP</a>
*/
V rightPop(K key);
/**
* Removes and returns last element from lists stored at {@code key}. <br>
* <b>Blocks connection</b> until element available or {@code timeout} reached.
*
* @param key must not be {@literal null}.
* @param timeout
* @param unit must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/brpop">Redis Documentation: BRPOP</a>
*/
V rightPop(K key, long timeout, TimeUnit unit);
/**
* Remove the last element from list at {@code sourceKey}, append it to {@code destinationKey} and return its value.
*
* @param sourceKey must not be {@literal null}.
* @param destinationKey must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/rpoplpush">Redis Documentation: RPOPLPUSH</a>
*/
V rightPopAndLeftPush(K sourceKey, K destinationKey);
/**
* Remove the last element from list at {@code srcKey}, append it to {@code dstKey} and return its value.<br>
* <b>Blocks connection</b> until element available or {@code timeout} reached.
*
* @param sourceKey must not be {@literal null}.
* @param destinationKey must not be {@literal null}.
* @param timeout
* @param unit must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/brpoplpush">Redis Documentation: BRPOPLPUSH</a>
*/
V rightPopAndLeftPush(K sourceKey, K destinationKey, long timeout, TimeUnit unit);
RedisOperations<K, V> getOperations();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2016 the original author or authors.
* Copyright 2011-2017 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 Costin Leau
* @author Christoph Strobl
* @author Ninad Divadkar
* @author Mark Paluch
*/
public interface RedisOperations<K, V> {
@@ -141,53 +142,272 @@ public interface RedisOperations<K, V> {
*/
<T extends Closeable> T executeWithStickyConnection(RedisCallback<T> callback);
// -------------------------------------------------------------------------
// Methods dealing with Redis Keys
// -------------------------------------------------------------------------
/**
* Determine if given {@code key} exists.
*
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/exists">Redis Documentation: EXISTS</a>
*/
Boolean hasKey(K key);
/**
* Delete given {@code key}.
*
* @param key must not be {@literal null}.
* @return The number of keys that were removed.
* @see <a href="http://redis.io/commands/del">Redis Documentation: DEL</a>
*/
void delete(K key);
void delete(Collection<K> key);
/**
* Delete given {@code keys}.
*
* @param keys must not be {@literal null}.
* @return The number of keys that were removed.
* @see <a href="http://redis.io/commands/del">Redis Documentation: DEL</a>
*/
void delete(Collection<K> keys);
/**
* Determine the type stored at {@code key}.
*
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/type">Redis Documentation: TYPE</a>
*/
DataType type(K key);
/**
* Find all keys matching the given {@code pattern}.
*
* @param pattern must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/keys">Redis Documentation: KEYS</a>
*/
Set<K> keys(K pattern);
/**
* Return a random key from the keyspace.
*
* @return
* @see <a href="http://redis.io/commands/randomkey">Redis Documentation: RANDOMKEY</a>
*/
K randomKey();
/**
* Rename key {@code oldKey} to {@code newKey}.
*
* @param oldKey must not be {@literal null}.
* @param newKey must not be {@literal null}.
* @see <a href="http://redis.io/commands/rename">Redis Documentation: RENAME</a>
*/
void rename(K oldKey, K newKey);
/**
* Rename key {@code oleName} to {@code newKey} only if {@code newKey} does not exist.
*
* @param oldKey must not be {@literal null}.
* @param newKey must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/renamenx">Redis Documentation: RENAMENX</a>
*/
Boolean renameIfAbsent(K oldKey, K newKey);
/**
* Set time to live for given {@code key}..
*
* @param key must not be {@literal null}.
* @param timeout
* @param unit must not be {@literal null}.
* @return
*/
Boolean expire(K key, long timeout, TimeUnit unit);
/**
* Set the expiration for given {@code key} as a {@literal date} timestamp.
*
* @param key must not be {@literal null}.
* @param date must not be {@literal null}.
* @return
*/
Boolean expireAt(K key, Date date);
/**
* Remove the expiration from given {@code key}.
*
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/persist">Redis Documentation: PERSIST</a>
*/
Boolean persist(K key);
/**
* Move given {@code key} to database with {@code index}.
*
* @param key must not be {@literal null}.
* @param dbIndex
* @return
* @see <a href="http://redis.io/commands/move">Redis Documentation: MOVE</a>
*/
Boolean move(K key, int dbIndex);
/**
* Retrieve serialized version of the value stored at {@code key}.
*
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/dump">Redis Documentation: DUMP</a>
*/
byte[] dump(K key);
/**
* Create {@code key} using the {@code serializedValue}, previously obtained using {@link #dump(Object)}.
*
* @param key must not be {@literal null}.
* @param value must not be {@literal null}.
* @param timeToLive
* @param unit must not be {@literal null}.
* @see <a href="http://redis.io/commands/restore">Redis Documentation: RESTORE</a>
*/
void restore(K key, byte[] value, long timeToLive, TimeUnit unit);
/**
* Get the time to live for {@code key} in seconds.
*
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/ttl">Redis Documentation: TTL</a>
*/
Long getExpire(K key);
/**
* Get the time to live for {@code key} in and convert it to the given {@link TimeUnit}.
*
* @param key must not be {@literal null}.
* @param timeUnit must not be {@literal null}.
* @return
* @since 1.8
*/
Long getExpire(K key, TimeUnit timeUnit);
void watch(K keys);
/**
* Sort the elements for {@code query}.
*
* @param query must not be {@literal null}.
* @return the results of sort.
* @see <a href="http://redis.io/commands/sort">Redis Documentation: SORT</a>
*/
List<V> sort(SortQuery<K> query);
/**
* Sort the elements for {@code query} applying {@link RedisSerializer}.
*
* @param query must not be {@literal null}.
* @return the deserialized results of sort.
* @see <a href="http://redis.io/commands/sort">Redis Documentation: SORT</a>
*/
<T> List<T> sort(SortQuery<K> query, RedisSerializer<T> resultSerializer);
/**
* Sort the elements for {@code query} applying {@link BulkMapper}.
*
* @param query must not be {@literal null}.
* @return the deserialized results of sort.
* @see <a href="http://redis.io/commands/sort">Redis Documentation: SORT</a>
*/
<T> List<T> sort(SortQuery<K> query, BulkMapper<T, V> bulkMapper);
/**
* Sort the elements for {@code query} applying {@link BulkMapper} and {@link RedisSerializer}.
*
* @param query must not be {@literal null}.
* @return the deserialized results of sort.
* @see <a href="http://redis.io/commands/sort">Redis Documentation: SORT</a>
*/
<T, S> List<T> sort(SortQuery<K> query, BulkMapper<T, S> bulkMapper, RedisSerializer<S> resultSerializer);
/**
* Sort the elements for {@code query} and store result in {@code storeKey}.
*
* @param query must not be {@literal null}.
* @param storeKey must not be {@literal null}.
* @return number of values.
* @see <a href="http://redis.io/commands/sort">Redis Documentation: SORT</a>
*/
Long sort(SortQuery<K> query, K storeKey);
// -------------------------------------------------------------------------
// Methods dealing with Redis Transactions
// -------------------------------------------------------------------------
/**
* Watch given {@code key} for modifications during transaction started with {@link #multi()}.
*
* @param key must not be {@literal null}.
* @see <a href="http://redis.io/commands/watch">Redis Documentation: WATCH</a>
*/
void watch(K key);
/**
* Watch given {@code keys} for modifications during transaction started with {@link #multi()}.
*
* @param keys must not be {@literal null}.
* @see <a href="http://redis.io/commands/watch">Redis Documentation: WATCH</a>
*/
void watch(Collection<K> keys);
/**
* Flushes all the previously {@link #watch(Object)} keys.
*
* @see <a href="http://redis.io/commands/unwatch">Redis Documentation: UNWATCH</a>
*/
void unwatch();
/**
* '
* Mark the start of a transaction block. <br>
* Commands will be queued and can then be executed by calling {@link #exec()} or rolled back using {@link #discard()}
* <p>
*
* @see <a href="http://redis.io/commands/multi">Redis Documentation: MULTI</a>
*/
void multi();
/**
* Discard all commands issued after {@link #multi()}.
*
* @see <a href="http://redis.io/commands/discard">Redis Documentation: DISCARD</a>
*/
void discard();
/**
* Executes all queued commands in a transaction started with {@link #multi()}. <br>
* If used along with {@link #watch(Object)} the operation will fail if any of watched keys has been modified.
*
* @return List of replies for each executed command.
* @see <a href="http://redis.io/commands/exec">Redis Documentation: EXEC</a>
*/
List<Object> exec();
/**
* Execute a transaction, using the provided {@link RedisSerializer} to deserialize any results that are byte[]s or
* Collections of byte[]s. If a result is a Map, the provided {@link RedisSerializer} will be used for both the keys
* and values. Other result types (Long, Boolean, etc) are left as-is in the converted results. Tuple results are
* automatically converted to TypedTuples.
*
* @param valueSerializer The {@link RedisSerializer} to use for deserializing the results of transaction exec
* @return The deserialized results of transaction exec
*/
List<Object> exec(RedisSerializer<?> valueSerializer);
// -------------------------------------------------------------------------
// Methods dealing with Redis Server Commands
// -------------------------------------------------------------------------
/**
* /** Request information and statistics about connected clients.
*
@@ -197,19 +417,46 @@ public interface RedisOperations<K, V> {
List<RedisClientInfo> getClientList();
/**
* Execute a transaction, using the provided {@link RedisSerializer} to deserialize any results that are byte[]s or
* Collections of byte[]s. If a result is a Map, the provided {@link RedisSerializer} will be used for both the keys
* and values. Other result types (Long, Boolean, etc) are left as-is in the converted results. Tuple results are
* automatically converted to TypedTuples.
*
* @param valueSerializer The {@link RedisSerializer} to use for deserializing the results of transaction exec
* @return The deserialized results of transaction exec
* Closes a given client connection identified by {@literal ip:port} given in {@code client}.
*
* @param host of connection to close.
* @param port of connection to close
* @since 1.3
*/
List<Object> exec(RedisSerializer<?> valueSerializer);
void killClient(String host, int port);
// pubsub functionality on the template
/**
* Change redis replication setting to new master.
*
* @param host must not be {@literal null}.
* @param port
* @since 1.3
* @see <a href="http://redis.io/commands/slaveof">Redis Documentation: SLAVEOF</a>
*/
void slaveOf(String host, int port);
/**
* Change server into master.
*
* @since 1.3
* @see <a href="http://redis.io/commands/slaveof">Redis Documentation: SLAVEOF</a>
*/
void slaveOfNoOne();
/**
* Publishes the given message to the given channel.
*
* @param destination the channel to publish to, must not be {@literal null}.
* @param message message to publish
* @return the number of clients that received the message
* @see <a href="http://redis.io/commands/publish">Redis Documentation: PUBLISH</a>
*/
void convertAndSend(String destination, Object message);
// -------------------------------------------------------------------------
// Methods to obtain specific operations interface objects.
// -------------------------------------------------------------------------
// operation types
/**
* Returns the operations performed on simple values (or Strings in Redis terminology).
@@ -321,46 +568,24 @@ public interface RedisOperations<K, V> {
*/
ClusterOperations<K, V> opsForCluster();
List<V> sort(SortQuery<K> query);
<T> List<T> sort(SortQuery<K> query, RedisSerializer<T> resultSerializer);
<T> List<T> sort(SortQuery<K> query, BulkMapper<T, V> bulkMapper);
<T, S> List<T> sort(SortQuery<K> query, BulkMapper<T, S> bulkMapper, RedisSerializer<S> resultSerializer);
Long sort(SortQuery<K> query, K storeKey);
RedisSerializer<?> getValueSerializer();
/**
* @return the key {@link RedisSerializer}.
*/
RedisSerializer<?> getKeySerializer();
/**
* @return the value {@link RedisSerializer}.
*/
RedisSerializer<?> getValueSerializer();
/**
* @return the hash key {@link RedisSerializer}.
*/
RedisSerializer<?> getHashKeySerializer();
/**
* @return the hash value {@link RedisSerializer}.
*/
RedisSerializer<?> getHashValueSerializer();
/**
* Closes a given client connection identified by {@literal ip:port} given in {@code client}.
*
* @param host of connection to close.
* @param port of connection to close
* @since 1.3
*/
void killClient(String host, int port);
/**
* Change redis replication setting to new master.
*
* @param host
* @param port
* @since 1.3
*/
void slaveOf(String host, int port);
/**
* Change server into master.
*
* @since 1.3
*/
void slaveOfNoOne();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2016 the original author or authors.
* Copyright 2011-2017 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.
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.redis.core;
import java.util.Collection;
@@ -25,63 +24,243 @@ import java.util.Set;
*
* @author Costin Leau
* @author Christoph Strobl
* @author Mark Paluch
*/
public interface SetOperations<K, V> {
Set<V> difference(K key, K otherKey);
Set<V> difference(K key, Collection<K> otherKeys);
Long differenceAndStore(K key, K otherKey, K destKey);
Long differenceAndStore(K key, Collection<K> otherKeys, K destKey);
Set<V> intersect(K key, K otherKey);
Set<V> intersect(K key, Collection<K> otherKeys);
Long intersectAndStore(K key, K otherKey, K destKey);
Long intersectAndStore(K key, Collection<K> otherKeys, K destKey);
Set<V> union(K key, K otherKey);
Set<V> union(K key, Collection<K> otherKeys);
Long unionAndStore(K key, K otherKey, K destKey);
Long unionAndStore(K key, Collection<K> otherKeys, K destKey);
/**
* Add given {@code values} to set at {@code key}.
*
* @param key must not be {@literal null}.
* @param values
* @return
* @see <a href="http://redis.io/commands/sadd">Redis Documentation: SADD</a>
*/
Long add(K key, V... values);
Boolean isMember(K key, Object o);
Set<V> members(K key);
Boolean move(K key, V value, K destKey);
V randomMember(K key);
Set<V> distinctRandomMembers(K key, long count);
List<V> randomMembers(K key, long count);
/**
* Remove given {@code values} from set at {@code key} and return the number of removed elements.
*
* @param key must not be {@literal null}.
* @param values
* @return
* @see <a href="http://redis.io/commands/srem">Redis Documentation: SREM</a>
*/
Long remove(K key, Object... values);
/**
* Remove and return a random member from set at {@code key}.
*
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/spop">Redis Documentation: SPOP</a>
*/
V pop(K key);
/**
* Move {@code value} from {@code key} to {@code destKey}
*
* @param key must not be {@literal null}.
* @param value
* @param destKey must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/smove">Redis Documentation: SMOVE</a>
*/
Boolean move(K key, V value, K destKey);
/**
* Get size of set at {@code key}.
*
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/scard">Redis Documentation: SCARD</a>
*/
Long size(K key);
RedisOperations<K, V> getOperations();
/**
* Check if set at {@code key} contains {@code value}.
*
* @param key must not be {@literal null}.
* @param o
* @return
* @see <a href="http://redis.io/commands/sismember">Redis Documentation: SISMEMBER</a>
*/
Boolean isMember(K key, Object o);
/**
* Returns the members intersecting all given sets at {@code key} and {@code otherKey}.
*
* @param key must not be {@literal null}.
* @param otherKey must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/sinter">Redis Documentation: SINTER</a>
*/
Set<V> intersect(K key, K otherKey);
/**
* Returns the members intersecting all given sets at {@code key} and {@code otherKeys}.
*
* @param key must not be {@literal null}.
* @param otherKeys must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/sinter">Redis Documentation: SINTER</a>
*/
Set<V> intersect(K key, Collection<K> otherKeys);
/**
* Intersect all given sets at {@code key} and {@code otherKey} and store result in {@code destKey}.
*
* @param key must not be {@literal null}.
* @param otherKey must not be {@literal null}.
* @param destKey must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/sinterstore">Redis Documentation: SINTERSTORE</a>
*/
Long intersectAndStore(K key, K otherKey, K destKey);
/**
* Intersect all given sets at {@code key} and {@code otherKeys} and store result in {@code destKey}.
*
* @param key must not be {@literal null}.
* @param otherKeys must not be {@literal null}.
* @param destKey must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/sinterstore">Redis Documentation: SINTERSTORE</a>
*/
Long intersectAndStore(K key, Collection<K> otherKeys, K destKey);
/**
* Union all sets at given {@code keys} and {@code otherKey}.
*
* @param key must not be {@literal null}.
* @param otherKey must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/sunion">Redis Documentation: SUNION</a>
*/
Set<V> union(K key, K otherKey);
/**
* Union all sets at given {@code keys} and {@code otherKeys}.
*
* @param key must not be {@literal null}.
* @param otherKeys must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/sunion">Redis Documentation: SUNION</a>
*/
Set<V> union(K key, Collection<K> otherKeys);
/**
* Union all sets at given {@code key} and {@code otherKey} and store result in {@code destKey}.
*
* @param key must not be {@literal null}.
* @param otherKey must not be {@literal null}.
* @param destKey must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/sunionstore">Redis Documentation: SUNIONSTORE</a>
*/
Long unionAndStore(K key, K otherKey, K destKey);
/**
* Union all sets at given {@code key} and {@code otherKeys} and store result in {@code destKey}.
*
* @param key must not be {@literal null}.
* @param otherKeys must not be {@literal null}.
* @param destKey must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/sunionstore">Redis Documentation: SUNIONSTORE</a>
*/
Long unionAndStore(K key, Collection<K> otherKeys, K destKey);
/**
* Diff all sets for given {@code key} and {@code otherKey}.
*
* @param key must not be {@literal null}.
* @param otherKey must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/sdiff">Redis Documentation: SDIFF</a>
*/
Set<V> difference(K key, K otherKey);
/**
* Diff all sets for given {@code key} and {@code otherKeys}.
*
* @param key must not be {@literal null}.
* @param otherKeys must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/sdiff">Redis Documentation: SDIFF</a>
*/
Set<V> difference(K key, Collection<K> otherKeys);
/**
* Diff all sets for given {@code key} and {@code otherKey} and store result in {@code destKey}.
*
* @param key must not be {@literal null}.
* @param otherKey must not be {@literal null}.
* @param destKey must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/sdiffstore">Redis Documentation: SDIFFSTORE</a>
*/
Long differenceAndStore(K key, K otherKey, K destKey);
/**
* Diff all sets for given {@code key} and {@code otherKeys} and store result in {@code destKey}.
*
* @param key must not be {@literal null}.
* @param otherKeys must not be {@literal null}.
* @param destKey must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/sdiffstore">Redis Documentation: SDIFFSTORE</a>
*/
Long differenceAndStore(K key, Collection<K> otherKeys, K destKey);
/**
* Get all elements of set at {@code key}.
*
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/smembers">Redis Documentation: SMEMBERS</a>
*/
Set<V> members(K key);
/**
* Get random element from set at {@code key}.
*
* @param key must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/srandmember">Redis Documentation: SRANDMEMBER</a>
*/
V randomMember(K key);
/**
* Get {@code count} distinct random elements from set at {@code key}.
*
* @param key must not be {@literal null}.
* @param count
* @return
* @see <a href="http://redis.io/commands/srandmember">Redis Documentation: SRANDMEMBER</a>
*/
Set<V> distinctRandomMembers(K key, long count);
/**
* Get {@code count} random elements from set at {@code key}.
*
* @param key must not be {@literal null}.
* @param count
* @return
* @see <a href="http://redis.io/commands/srandmember">Redis Documentation: SRANDMEMBER</a>
*/
List<V> randomMembers(K key, long count);
/**
* Iterate over elements in set at {@code key}. <br />
* <strong>Important:</strong> Call {@link Cursor#close()} when done to avoid resource leak.
*
* @since 1.4
* @param key
* @param options
* @return
* @since 1.4
*/
Cursor<V> scan(K key, ScanOptions options);
RedisOperations<K, V> getOperations();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2014 the original author or authors.
* Copyright 2011-2017 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.
@@ -25,63 +25,156 @@ import java.util.concurrent.TimeUnit;
*
* @author Costin Leau
* @author Christoph Strobl
* @author Mark Paluch
*/
public interface ValueOperations<K, V> {
/**
* Set {@code value} for {@code key}.
*
* @param key must not be {@literal null}.
* @param value
* @see <a href="http://redis.io/commands/set">Redis Documentation: SET</a>
*/
void set(K key, V value);
/**
* Set {@code key} to hold the string {@code value} until {@code timeout}.
*
* @param key
* Set the {@code value} and expiration {@code timeout} for {@code key}.
*
* @param key must not be {@literal null}.
* @param value
* @param timeout
* @param units
* @see http://redis.io/commands/set
* @param unit must not be {@literal null}.
* @see <a href="http://redis.io/commands/setex">Redis Documentation: SETEX</a>
*/
void set(K key, V value, long timeout, TimeUnit unit);
/**
* Set {@code key} to hold the string {@code value} if {@code key} is absent.
*
* @param key must not be {@literal null}.
* @param value
* @see <a href="http://redis.io/commands/setnx">Redis Documentation: SETNX</a>
*/
Boolean setIfAbsent(K key, V value);
void multiSet(Map<? extends K, ? extends V> m);
/**
* Set multiple keys to multiple values using key-value pairs provided in {@code tuple}.
*
* @param map must not be {@literal null}.
* @see <a href="http://redis.io/commands/mset">Redis Documentation: MSET</a>
*/
void multiSet(Map<? extends K, ? extends V> map);
Boolean multiSetIfAbsent(Map<? extends K, ? extends V> m);
/**
* Set multiple keys to multiple values using key-value pairs provided in {@code tuple} only if the provided key does
* not exist.
*
* @param map must not be {@literal null}.
* @see <a href="http://redis.io/commands/mset">Redis Documentation: MSET</a>
*/
Boolean multiSetIfAbsent(Map<? extends K, ? extends V> map);
/**
* Get the value of {@code key}.
*
* @param key must not be {@literal null}.
* @see <a href="http://redis.io/commands/get">Redis Documentation: GET</a>
*/
V get(Object key);
/**
* Set {@code value} of {@code key} and return its old value.
*
* @param key must not be {@literal null}.
* @see <a href="http://redis.io/commands/getset">Redis Documentation: GETSET</a>
*/
V getAndSet(K key, V value);
/**
* Get multiple {@code keys}. Values are returned in the order of the requested keys.
*
* @param keys must not be {@literal null}.
* @see <a href="http://redis.io/commands/mget">Redis Documentation: MGET</a>
*/
List<V> multiGet(Collection<K> keys);
/**
* Increment an integer value stored as string value under {@code key} by {@code delta}.
*
* @param key must not be {@literal null}.
* @param delta
* @see <a href="http://redis.io/commands/incr">Redis Documentation: INCR</a>
*/
Long increment(K key, long delta);
/**
* Increment a floating point number value stored as string value under {@code key} by {@code delta}.
*
* @param key must not be {@literal null}.
* @param delta
* @see <a href="http://redis.io/commands/incrbyfloar">Redis Documentation: INCRBYFLOAT</a>
*/
Double increment(K key, double delta);
/**
* Append a {@code value} to {@code key}.
*
* @param key must not be {@literal null}.
* @param value
* @see <a href="http://redis.io/commands/append">Redis Documentation: APPEND</a>
*/
Integer append(K key, String value);
/**
* Get a substring of value of {@code key} between {@code begin} and {@code end}.
*
* @param key must not be {@literal null}.
* @param start
* @param end
* @see <a href="http://redis.io/commands/getrange">Redis Documentation: GETRANGE</a>
*/
String get(K key, long start, long end);
/**
* Overwrite parts of {@code key} starting at the specified {@code offset} with given {@code value}.
*
* @param key must not be {@literal null}.
* @param value
* @param offset
* @see <a href="http://redis.io/commands/setrange">Redis Documentation: SETRANGE</a>
*/
void set(K key, V value, long offset);
/**
* Get the length of the value stored at {@code key}.
*
* @param key must not be {@literal null}.
* @see <a href="http://redis.io/commands/strlen">Redis Documentation: STRLEN</a>
*/
Long size(K key);
RedisOperations<K, V> getOperations();
/**
* @since 1.5
* @param key
* Sets the bit at {@code offset} in value stored at {@code key}.
*
* @param key must not be {@literal null}.
* @param offset
* @param value
* @return
* @since 1.5
* @see <a href="http://redis.io/commands/setbit">Redis Documentation: SETBIT</a>
*/
Boolean setBit(K key, long offset, boolean value);
/**
* @since 1.5
* @param key
* Get the bit value at {@code offset} of value at {@code key}.
*
* @param key must not be {@literal null}.
* @param offset
* @return
* @since 1.5
* @see <a href="http://redis.io/commands/setbit">Redis Documentation: GETBIT</a>
*/
Boolean getBit(K key, long offset);
RedisOperations<K, V> getOperations();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2016 the original author or authors.
* Copyright 2011-2017 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.
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.redis.core;
import java.util.Collection;
@@ -21,6 +20,7 @@ import java.util.Set;
import org.springframework.data.redis.connection.RedisZSetCommands.Limit;
import org.springframework.data.redis.connection.RedisZSetCommands.Range;
import org.springframework.data.redis.connection.RedisZSetCommands.Tuple;
/**
* Redis ZSet/sorted set specific operations.
@@ -40,29 +40,339 @@ public interface ZSetOperations<K, V> {
Double getScore();
}
Long intersectAndStore(K key, K otherKey, K destKey);
/**
* Add {@code value} to a sorted set at {@code key}, or update its {@code score} if it already exists.
*
* @param key must not be {@literal null}.
* @param score the score.
* @param value the value.
* @return
* @see <a href="http://redis.io/commands/zadd">Redis Documentation: ZADD</a>
*/
Boolean add(K key, V value, double score);
Long intersectAndStore(K key, Collection<K> otherKeys, K destKey);
/**
* Add {@code tuples} to a sorted set at {@code key}, or update its {@code score} if it already exists.
*
* @param key must not be {@literal null}.
* @param tuples must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/zadd">Redis Documentation: ZADD</a>
*/
Long add(K key, Set<TypedTuple<V>> tuples);
Long unionAndStore(K key, K otherKey, K destKey);
/**
* Remove {@code values} from sorted set. Return number of removed elements.
*
* @param key must not be {@literal null}.
* @param values must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/zrem">Redis Documentation: ZREM</a>
*/
Long remove(K key, Object... values);
Long unionAndStore(K key, Collection<K> otherKeys, K destKey);
/**
* Increment the score of element with {@code value} in sorted set by {@code increment}.
*
* @param key must not be {@literal null}.
* @param delta
* @param value the value.
* @return
* @see <a href="http://redis.io/commands/zincrby">Redis Documentation: ZINCRBY</a>
*/
Double incrementScore(K key, V value, double delta);
/**
* Determine the index of element with {@code value} in a sorted set.
*
* @param key must not be {@literal null}.
* @param o the value.
* @return
* @see <a href="http://redis.io/commands/zrank">Redis Documentation: ZRANK</a>
*/
Long rank(K key, Object o);
/**
* Determine the index of element with {@code value} in a sorted set when scored high to low.
*
* @param key must not be {@literal null}.
* @param o the value.
* @return
* @see <a href="http://redis.io/commands/zrevrank">Redis Documentation: ZREVRANK</a>
*/
Long reverseRank(K key, Object o);
/**
* Get elements between {@code start} and {@code end} from sorted set.
*
* @param key must not be {@literal null}.
* @param start
* @param end
* @return
* @see <a href="http://redis.io/commands/zrange">Redis Documentation: ZRANGE</a>
*/
Set<V> range(K key, long start, long end);
Set<V> reverseRange(K key, long start, long end);
/**
* Get set of {@link Tuple}s between {@code start} and {@code end} from sorted set.
*
* @param key must not be {@literal null}.
* @param start
* @param end
* @return
* @see <a href="http://redis.io/commands/zrange">Redis Documentation: ZRANGE</a>
*/
Set<TypedTuple<V>> rangeWithScores(K key, long start, long end);
/**
* Get elements where score is between {@code min} and {@code max} from sorted set.
*
* @param key must not be {@literal null}.
* @param min
* @param max
* @return
* @see <a href="http://redis.io/commands/zrangebyscore">Redis Documentation: ZRANGEBYSCORE</a>
*/
Set<V> rangeByScore(K key, double min, double max);
/**
* Get set of {@link Tuple}s where score is between {@code min} and {@code max} from sorted set.
*
* @param key must not be {@literal null}.
* @param min
* @param max
* @return
* @see <a href="http://redis.io/commands/zrangebyscore">Redis Documentation: ZRANGEBYSCORE</a>
*/
Set<TypedTuple<V>> rangeByScoreWithScores(K key, double min, double max);
/**
* Get elements in range from {@code start} to {@code end} where score is between {@code min} and {@code max} from
* sorted set.
*
* @param key must not be {@literal null}.
* @param min
* @param max
* @param offset
* @param count
* @return
* @see <a href="http://redis.io/commands/zrangebyscore">Redis Documentation: ZRANGEBYSCORE</a>
*/
Set<V> rangeByScore(K key, double min, double max, long offset, long count);
/**
* Get set of {@link Tuple}s in range from {@code start} to {@code end} where score is between {@code min} and
* {@code max} from sorted set.
*
* @param key
* @param min
* @param max
* @param offset
* @param count
* @return
* @see <a href="http://redis.io/commands/zrangebyscore">Redis Documentation: ZRANGEBYSCORE</a>
*/
Set<TypedTuple<V>> rangeByScoreWithScores(K key, double min, double max, long offset, long count);
/**
* Get elements in range from {@code start} to {@code end} from sorted set ordered from high to low.
*
* @param key must not be {@literal null}.
* @param start
* @param end
* @return
* @see <a href="http://redis.io/commands/zrevrange">Redis Documentation: ZREVRANGE</a>
*/
Set<V> reverseRange(K key, long start, long end);
/**
* Get set of {@link Tuple}s in range from {@code start} to {@code end} from sorted set ordered from high to low.
*
* @param key must not be {@literal null}.
* @param start
* @param end
* @return
* @see <a href="http://redis.io/commands/zrevrange">Redis Documentation: ZREVRANGE</a>
*/
Set<TypedTuple<V>> reverseRangeWithScores(K key, long start, long end);
/**
* Get elements where score is between {@code min} and {@code max} from sorted set ordered from high to low.
*
* @param key must not be {@literal null}.
* @param min
* @param max
* @return
* @see <a href="http://redis.io/commands/zrevrange">Redis Documentation: ZREVRANGE</a>
*/
Set<V> reverseRangeByScore(K key, double min, double max);
/**
* Get set of {@link Tuple} where score is between {@code min} and {@code max} from sorted set ordered from high to
* low.
*
* @param key must not be {@literal null}.
* @param min
* @param max
* @return
* @see <a href="http://redis.io/commands/zrevrangebyscore">Redis Documentation: ZREVRANGEBYSCORE</a>
*/
Set<TypedTuple<V>> reverseRangeByScoreWithScores(K key, double min, double max);
/**
* Get elements in range from {@code start} to {@code end} where score is between {@code min} and {@code max} from
* sorted set ordered high -> low.
*
* @param key must not be {@literal null}.
* @param min
* @param max
* @param offset
* @param count
* @return
* @see <a href="http://redis.io/commands/zrevrangebyscore">Redis Documentation: ZREVRANGEBYSCORE</a>
*/
Set<V> reverseRangeByScore(K key, double min, double max, long offset, long count);
/**
* Get set of {@link Tuple} in range from {@code start} to {@code end} where score is between {@code min} and
* {@code max} from sorted set ordered high -> low.
*
* @param key must not be {@literal null}.
* @param min
* @param max
* @param offset
* @param count
* @return
* @see <a href="http://redis.io/commands/zrevrangebyscore">Redis Documentation: ZREVRANGEBYSCORE</a>
*/
Set<TypedTuple<V>> reverseRangeByScoreWithScores(K key, double min, double max, long offset, long count);
/**
* Count number of elements within sorted set with scores between {@code min} and {@code max}.
*
* @param key must not be {@literal null}.
* @param min
* @param max
* @return
* @see <a href="http://redis.io/commands/zcount">Redis Documentation: ZCOUNT</a>
*/
Long count(K key, double min, double max);
/**
* Returns the number of elements of the sorted set stored with given {@code key}.
*
* @see #zCard(Object)
* @param key
* @return
* @see <a href="http://redis.io/commands/zcard">Redis Documentation: ZCARD</a>
*/
Long size(K key);
/**
* Get the size of sorted set with {@code key}.
*
* @param key must not be {@literal null}.
* @return
* @since 1.3
* @see <a href="http://redis.io/commands/zcard">Redis Documentation: ZCARD</a>
*/
Long zCard(K key);
/**
* Get the score of element with {@code value} from sorted set with key {@code key}.
*
* @param key must not be {@literal null}.
* @param o the value.
* @return
* @see <a href="http://redis.io/commands/zrem">Redis Documentation: ZREM</a>
*/
Double score(K key, Object o);
/**
* Remove elements in range between {@code start} and {@code end} from sorted set with {@code key}.
*
* @param key must not be {@literal null}.
* @param start
* @param end
* @return
* @see <a href="http://redis.io/commands/zremrangebyrank">Redis Documentation: ZREMRANGEBYRANK</a>
*/
Long removeRange(K key, long start, long end);
/**
* Remove elements with scores between {@code min} and {@code max} from sorted set with {@code key}.
*
* @param key must not be {@literal null}.
* @param min
* @param max
* @return
* @see <a href="http://redis.io/commands/zremrangebyscore">Redis Documentation: ZREMRANGEBYSCORE</a>
*/
Long removeRangeByScore(K key, double min, double max);
/**
* Union sorted sets at {@code key} and {@code otherKeys} and store result in destination {@code destKey}.
*
* @param key must not be {@literal null}.
* @param otherKey must not be {@literal null}.
* @param destKey must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/zunionstore">Redis Documentation: ZUNIONSTORE</a>
*/
Long unionAndStore(K key, K otherKey, K destKey);
/**
* Union sorted sets at {@code key} and {@code otherKeys} and store result in destination {@code destKey}.
*
* @param key must not be {@literal null}.
* @param otherKeys must not be {@literal null}.
* @param destKey must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/zunionstore">Redis Documentation: ZUNIONSTORE</a>
*/
Long unionAndStore(K key, Collection<K> otherKeys, K destKey);
/**
* Intersect sorted sets at {@code key} and {@code otherKey} and store result in destination {@code destKey}.
*
* @param key must not be {@literal null}.
* @param otherKey must not be {@literal null}.
* @param destKey must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/zinterstore">Redis Documentation: ZINTERSTORE</a>
*/
Long intersectAndStore(K key, K otherKey, K destKey);
/**
* Intersect sorted sets at {@code key} and {@code otherKeys} and store result in destination {@code destKey}.
*
* @param key must not be {@literal null}.
* @param otherKeys must not be {@literal null}.
* @param destKey must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/zinterstore">Redis Documentation: ZINTERSTORE</a>
*/
Long intersectAndStore(K key, Collection<K> otherKeys, K destKey);
/**
* Iterate over elements in zset at {@code key}. <br />
* <strong>Important:</strong> Call {@link Cursor#close()} when done to avoid resource leak.
*
* @param key
* @param options
* @return
* @since 1.4
*/
Cursor<TypedTuple<V>> scan(K key, ScanOptions options);
/**
* Get all elements with lexicographical ordering from {@literal ZSET} at {@code key} with a value between
* {@link Range#getMin()} and {@link Range#getMax()}.
*
*
* @param key must not be {@literal null}.
* @param range must not be {@literal null}.
* @since 1.7
* @see <a href="http://redis.io/commands/zrangebylex">Redis Documentation: ZRANGEBYLEX</a>
*/
Set<V> rangeByLex(K key, Range range);
@@ -70,79 +380,15 @@ public interface ZSetOperations<K, V> {
* Get all elements {@literal n} elements, where {@literal n = } {@link Limit#getCount()}, starting at
* {@link Limit#getOffset()} with lexicographical ordering from {@literal ZSET} at {@code key} with a value between
* {@link Range#getMin()} and {@link Range#getMax()}.
*
*
* @param key must not be {@literal null}
* @param range must not be {@literal null}.
* @param limit can be {@literal null}.
* @return
* @since 1.7
* @see <a href="http://redis.io/commands/zrangebylex">Redis Documentation: ZRANGEBYLEX</a>
*/
Set<V> rangeByLex(K key, Range range, Limit limit);
Set<V> rangeByScore(K key, double min, double max);
Set<V> rangeByScore(K key, double min, double max, long offset, long count);
Set<V> reverseRangeByScore(K key, double min, double max);
Set<V> reverseRangeByScore(K key, double min, double max, long offset, long count);
Set<TypedTuple<V>> rangeByScoreWithScores(K key, double min, double max);
Set<TypedTuple<V>> rangeByScoreWithScores(K key, double min, double max, long offset, long count);
Set<TypedTuple<V>> reverseRangeByScoreWithScores(K key, double min, double max);
Set<TypedTuple<V>> reverseRangeByScoreWithScores(K key, double min, double max, long offset, long count);
Boolean add(K key, V value, double score);
Long add(K key, Set<TypedTuple<V>> tuples);
Double incrementScore(K key, V value, double delta);
Long rank(K key, Object o);
Long reverseRank(K key, Object o);
Double score(K key, Object o);
Long remove(K key, Object... values);
Long removeRange(K key, long start, long end);
Long removeRangeByScore(K key, double min, double max);
Long count(K key, double min, double max);
/**
* Returns the number of elements of the sorted set stored with given {@code key}.
*
* @see #zCard(Object)
* @param key
* @return
*/
Long size(K key);
/**
* Returns the number of elements of the sorted set stored with given {@code key}.
*
* @param key
* @return
* @since 1.3
*/
Long zCard(K key);
RedisOperations<K, V> getOperations();
/**
* Iterate over elements in zset at {@code key}. <br />
* <strong>Important:</strong> Call {@link Cursor#close()} when done to avoid resource leak.
*
* @since 1.4
* @param key
* @param options
* @return
*/
Cursor<TypedTuple<V>> scan(K key, ScanOptions options);
}