diff --git a/src/main/java/org/springframework/data/redis/connection/HyperLogLogCommands.java b/src/main/java/org/springframework/data/redis/connection/HyperLogLogCommands.java index 63cb2de6e..7869202f1 100644 --- a/src/main/java/org/springframework/data/redis/connection/HyperLogLogCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/HyperLogLogCommands.java @@ -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 Redis Documentation: PFADD */ 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 Redis Documentation: PFCOUNT */ 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 Redis Documentation: PFMERGE */ void pfMerge(byte[] destinationKey, byte[]... sourceKeys); diff --git a/src/main/java/org/springframework/data/redis/connection/ReactiveGeoCommands.java b/src/main/java/org/springframework/data/redis/connection/ReactiveGeoCommands.java index c58e95c40..0f4018932 100644 --- a/src/main/java/org/springframework/data/redis/connection/ReactiveGeoCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/ReactiveGeoCommands.java @@ -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 reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Collection; @@ -42,9 +45,6 @@ import org.springframework.data.redis.connection.RedisGeoCommands.GeoRadiusComma import org.springframework.data.redis.connection.RedisGeoCommands.GeoRadiusCommandArgs.Flag; import org.springframework.util.Assert; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - /** * Redis Geo commands executed using reactive infrastructure. * @@ -58,6 +58,7 @@ public interface ReactiveGeoCommands { * {@code GEOADD} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: GEOADD */ class GeoAddCommand extends KeyCommand { @@ -121,6 +122,7 @@ public interface ReactiveGeoCommands { * @param point must not be {@literal null}. * @param member must not be {@literal null}. * @return + * @see Redis Documentation: GEOADD */ default Mono geoAdd(ByteBuffer key, Point point, ByteBuffer member) { @@ -137,6 +139,7 @@ public interface ReactiveGeoCommands { * @param key must not be {@literal null}. * @param location must not be {@literal null}. * @return + * @see Redis Documentation: GEOADD */ default Mono geoAdd(ByteBuffer key, GeoLocation location) { @@ -152,6 +155,7 @@ public interface ReactiveGeoCommands { * @param key must not be {@literal null}. * @param locations must not be {@literal null}. * @return + * @see Redis Documentation: GEOADD */ default Mono geoAdd(ByteBuffer key, Collection> locations) { @@ -166,6 +170,7 @@ public interface ReactiveGeoCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: GEOADD */ Flux> geoAdd(Publisher commands); @@ -173,6 +178,7 @@ public interface ReactiveGeoCommands { * {@code GEODIST} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: GEODIST */ class GeoDistCommand extends KeyCommand { @@ -298,6 +304,7 @@ public interface ReactiveGeoCommands { * @param from must not be {@literal null}. * @param to must not be {@literal null}. * @return + * @see Redis Documentation: GEODIST */ default Mono geoDist(ByteBuffer key, ByteBuffer from, ByteBuffer to) { return geoDist(key, from, to, null); @@ -311,6 +318,7 @@ public interface ReactiveGeoCommands { * @param to must not be {@literal null}. * @param metric can be {@literal null} and defaults to {@link DistanceUnit#METERS}. * @return + * @see Redis Documentation: GEODIST */ default Mono geoDist(ByteBuffer key, ByteBuffer from, ByteBuffer to, Metric metric) { @@ -328,6 +336,7 @@ public interface ReactiveGeoCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: GEODIST */ Flux> geoDist(Publisher commands); @@ -335,6 +344,7 @@ public interface ReactiveGeoCommands { * {@code GEOHASH} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: GEOHASH */ class GeoHashCommand extends KeyCommand { @@ -400,6 +410,7 @@ public interface ReactiveGeoCommands { * @param key must not be {@literal null}. * @param member must not be {@literal null}. * @return + * @see Redis Documentation: GEOHASH */ default Mono geoHash(ByteBuffer key, ByteBuffer member) { @@ -415,6 +426,7 @@ public interface ReactiveGeoCommands { * @param key must not be {@literal null}. * @param members must not be {@literal null}. * @return + * @see Redis Documentation: GEOHASH */ default Mono> geoHash(ByteBuffer key, Collection members) { @@ -431,6 +443,7 @@ public interface ReactiveGeoCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: GEOHASH */ Flux> geoHash(Publisher commands); @@ -438,6 +451,7 @@ public interface ReactiveGeoCommands { * {@code GEOPOS} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: GEOPOS */ class GeoPosCommand extends KeyCommand { @@ -503,6 +517,7 @@ public interface ReactiveGeoCommands { * @param key must not be {@literal null}. * @param member must not be {@literal null}. * @return + * @see Redis Documentation: GEOPOS */ default Mono geoPos(ByteBuffer key, ByteBuffer member) { @@ -517,6 +532,7 @@ public interface ReactiveGeoCommands { * @param key must not be {@literal null}. * @param members must not be {@literal null}. * @return + * @see Redis Documentation: GEOPOS */ default Mono> geoPos(ByteBuffer key, Collection members) { @@ -531,6 +547,7 @@ public interface ReactiveGeoCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: GEOPOS */ Flux> geoPos(Publisher commands); @@ -538,6 +555,7 @@ public interface ReactiveGeoCommands { * {@code GEORADIUS} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: GEORADIUS */ class GeoRadiusCommand extends KeyCommand { @@ -838,6 +856,7 @@ public interface ReactiveGeoCommands { * @param key must not be {@literal null}. * @param circle must not be {@literal null}. * @return + * @see Redis Documentation: GEORADIUS */ default Mono>> geoRadius(ByteBuffer key, Circle circle) { return geoRadius(key, circle, null) @@ -851,6 +870,7 @@ public interface ReactiveGeoCommands { * @param circle must not be {@literal null}. * @param geoRadiusArgs can be {@literal null}. * @return + * @see Redis Documentation: GEORADIUS */ default Mono>> geoRadius(ByteBuffer key, Circle circle, GeoRadiusCommandArgs geoRadiusArgs) { @@ -867,6 +887,7 @@ public interface ReactiveGeoCommands { * * @param commands * @return + * @see Redis Documentation: GEORADIUS */ Flux>>> geoRadius( Publisher commands); @@ -875,6 +896,7 @@ public interface ReactiveGeoCommands { * {@code GEORADIUSBYMEMBER} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: GEORADIUSBYMEMBER */ class GeoRadiusByMemberCommand extends KeyCommand { @@ -1159,6 +1181,7 @@ public interface ReactiveGeoCommands { * @param key must not be {@literal null}. * @param member must not be {@literal null}. * @return + * @see Redis Documentation: GEORADIUSBYMEMBER */ default Mono>> geoRadiusByMember(ByteBuffer key, ByteBuffer member, Distance distance) { return geoRadiusByMember(key, member, distance, null) @@ -1172,6 +1195,7 @@ public interface ReactiveGeoCommands { * @param member must not be {@literal null}. * @param geoRadiusArgs can be {@literal null}. * @return + * @see Redis Documentation: GEORADIUSBYMEMBER */ default Mono>> geoRadiusByMember(ByteBuffer key, ByteBuffer member, Distance distance, GeoRadiusCommandArgs geoRadiusArgs) { @@ -1190,6 +1214,7 @@ public interface ReactiveGeoCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: GEORADIUSBYMEMBER */ Flux>>> geoRadiusByMember( Publisher commands); diff --git a/src/main/java/org/springframework/data/redis/connection/ReactiveHashCommands.java b/src/main/java/org/springframework/data/redis/connection/ReactiveHashCommands.java index 988e6db6d..df64c100b 100644 --- a/src/main/java/org/springframework/data/redis/connection/ReactiveHashCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/ReactiveHashCommands.java @@ -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 reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Collection; @@ -32,9 +35,6 @@ import org.springframework.data.redis.connection.ReactiveRedisConnection.MultiVa import org.springframework.data.redis.connection.ReactiveRedisConnection.NumericResponse; import org.springframework.util.Assert; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - /** * Redis Hash commands executed using reactive infrastructure. * @@ -48,6 +48,7 @@ public interface ReactiveHashCommands { * {@literal HSET} {@link Command}. * * @author Christoph Strobl + * @see Redis Documentation: HSET */ class HSetCommand extends KeyCommand { @@ -150,6 +151,7 @@ public interface ReactiveHashCommands { * @param field must not be {@literal null}. * @param value must not be {@literal null}. * @return + * @see Redis Documentation: HSET */ default Mono hSet(ByteBuffer key, ByteBuffer field, ByteBuffer value) { @@ -167,6 +169,7 @@ public interface ReactiveHashCommands { * @param field must not be {@literal null}. * @param value must not be {@literal null}. * @return + * @see Redis Documentation: HSETNX */ default Mono hSetNX(ByteBuffer key, ByteBuffer field, ByteBuffer value) { @@ -184,6 +187,7 @@ public interface ReactiveHashCommands { * @param key must not be {@literal null}. * @param fieldValueMap must not be {@literal null}. * @return + * @see Redis Documentation: HMSET */ default Mono hMSet(ByteBuffer key, Map fieldValueMap) { @@ -199,6 +203,7 @@ public interface ReactiveHashCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: HSET */ Flux> hSet(Publisher commands); @@ -206,6 +211,7 @@ public interface ReactiveHashCommands { * {@literal HGET} {@link Command}. * * @author Christoph Strobl + * @see Redis Documentation: HGET */ class HGetCommand extends KeyCommand { @@ -271,6 +277,7 @@ public interface ReactiveHashCommands { * @param key must not be {@literal null}. * @param field must not be {@literal null}. * @return + * @see Redis Documentation: HGET */ default Mono hGet(ByteBuffer key, ByteBuffer field) { return hMGet(key, Collections.singletonList(field)).map(val -> val.isEmpty() ? null : val.iterator().next()); @@ -282,6 +289,7 @@ public interface ReactiveHashCommands { * @param key must not be {@literal null}. * @param fields must not be {@literal null}. * @return + * @see Redis Documentation: HMGET */ default Mono> hMGet(ByteBuffer key, Collection fields) { @@ -296,6 +304,7 @@ public interface ReactiveHashCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: HMGET */ Flux> hMGet(Publisher commands); @@ -303,6 +312,7 @@ public interface ReactiveHashCommands { * {@literal HEXISTS} {@link Command}. * * @author Christoph Strobl + * @see Redis Documentation: HEXISTS */ class HExistsCommand extends KeyCommand { @@ -355,6 +365,7 @@ public interface ReactiveHashCommands { * @param key must not be {@literal null}. * @param field must not be {@literal null}. * @return + * @see Redis Documentation: HEXISTS */ default Mono hExists(ByteBuffer key, ByteBuffer field) { @@ -369,11 +380,13 @@ public interface ReactiveHashCommands { * * @param commands * @return + * @see Redis Documentation: HEXISTS */ Flux> hExists(Publisher commands); /** * @author Christoph Strobl + * @see Redis Documentation: HDEL */ class HDelCommand extends KeyCommand { @@ -439,6 +452,7 @@ public interface ReactiveHashCommands { * @param key must not be {@literal null}. * @param field must not be {@literal null}. * @return + * @see Redis Documentation: HDEL */ default Mono hDel(ByteBuffer key, ByteBuffer field) { @@ -453,6 +467,7 @@ public interface ReactiveHashCommands { * @param key must not be {@literal null}. * @param fields must not be {@literal null}. * @return + * @see Redis Documentation: HDEL */ default Mono hDel(ByteBuffer key, Collection fields) { @@ -467,6 +482,7 @@ public interface ReactiveHashCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: HDEL */ Flux> hDel(Publisher commands); @@ -475,6 +491,7 @@ public interface ReactiveHashCommands { * * @param key must not be {@literal null}. * @return + * @see Redis Documentation: HLEN */ default Mono hLen(ByteBuffer key) { @@ -488,6 +505,7 @@ public interface ReactiveHashCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: HLEN */ Flux> hLen(Publisher commands); @@ -496,6 +514,7 @@ public interface ReactiveHashCommands { * * @param key must not be {@literal null}. * @return + * @see Redis Documentation: HKEYS */ default Mono> hKeys(ByteBuffer key) { @@ -509,6 +528,7 @@ public interface ReactiveHashCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: HKEYS */ Flux> hKeys(Publisher commands); @@ -517,6 +537,7 @@ public interface ReactiveHashCommands { * * @param key must not be {@literal null}. * @return + * @see Redis Documentation: HVALS */ default Mono> hVals(ByteBuffer key) { @@ -530,6 +551,7 @@ public interface ReactiveHashCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: HVALS */ Flux> hVals(Publisher commands); @@ -538,6 +560,7 @@ public interface ReactiveHashCommands { * * @param key must not be {@literal null}. * @return + * @see Redis Documentation: HGETALL */ default Mono> hGetAll(ByteBuffer key) { @@ -551,6 +574,7 @@ public interface ReactiveHashCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: HGETALL */ Flux>> hGetAll(Publisher commands); } diff --git a/src/main/java/org/springframework/data/redis/connection/ReactiveHyperLogLogCommands.java b/src/main/java/org/springframework/data/redis/connection/ReactiveHyperLogLogCommands.java index 54c04f454..1188f5692 100644 --- a/src/main/java/org/springframework/data/redis/connection/ReactiveHyperLogLogCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/ReactiveHyperLogLogCommands.java @@ -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 reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Collection; @@ -28,9 +31,6 @@ import org.springframework.data.redis.connection.ReactiveRedisConnection.KeyComm import org.springframework.data.redis.connection.ReactiveRedisConnection.NumericResponse; import org.springframework.util.Assert; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - /** * Redis HyperLogLog commands executed using reactive infrastructure. * @@ -44,6 +44,7 @@ public interface ReactiveHyperLogLogCommands { * {@code PFADD} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: PFADD */ class PfAddCommand extends KeyCommand { @@ -108,6 +109,7 @@ public interface ReactiveHyperLogLogCommands { * @param key must not be {@literal null}. * @param value must not be {@literal null}. * @return + * @see Redis Documentation: PFADD */ default Mono pfAdd(ByteBuffer key, ByteBuffer value) { @@ -122,6 +124,7 @@ public interface ReactiveHyperLogLogCommands { * @param key must not be {@literal null}. * @param values must not be {@literal null}. * @return + * @see Redis Documentation: PFADD */ default Mono pfAdd(ByteBuffer key, Collection values) { @@ -136,6 +139,7 @@ public interface ReactiveHyperLogLogCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: PFADD */ Flux> pfAdd(Publisher commands); @@ -143,6 +147,7 @@ public interface ReactiveHyperLogLogCommands { * {@code PFCOUNT} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: PFCOUNT */ class PfCountCommand implements Command { @@ -201,6 +206,7 @@ public interface ReactiveHyperLogLogCommands { * * @param key must not be {@literal null}. * @return + * @see Redis Documentation: PFCOUNT */ default Mono pfCount(ByteBuffer key) { @@ -214,6 +220,7 @@ public interface ReactiveHyperLogLogCommands { * * @param keys must not be {@literal null}. * @return + * @see Redis Documentation: PFCOUNT */ default Mono pfCount(Collection keys) { @@ -227,6 +234,7 @@ public interface ReactiveHyperLogLogCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: PFCOUNT */ Flux> pfCount(Publisher commands); @@ -234,6 +242,7 @@ public interface ReactiveHyperLogLogCommands { * {@code PFMERGE} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: PFMERGE */ class PfMergeCommand extends KeyCommand { @@ -286,6 +295,7 @@ public interface ReactiveHyperLogLogCommands { * @param destinationKey must not be {@literal null}. * @param sourceKeys must not be {@literal null}. * @return + * @see Redis Documentation: PFMERGE */ default Mono pfMerge(ByteBuffer destinationKey, Collection sourceKeys) { @@ -301,6 +311,7 @@ public interface ReactiveHyperLogLogCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: PFMERGE */ Flux> pfMerge(Publisher commands); } diff --git a/src/main/java/org/springframework/data/redis/connection/ReactiveKeyCommands.java b/src/main/java/org/springframework/data/redis/connection/ReactiveKeyCommands.java index f803a72b4..47985840e 100644 --- a/src/main/java/org/springframework/data/redis/connection/ReactiveKeyCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/ReactiveKeyCommands.java @@ -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 reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + import java.nio.ByteBuffer; import java.util.List; @@ -26,9 +29,6 @@ import org.springframework.data.redis.connection.ReactiveRedisConnection.MultiVa import org.springframework.data.redis.connection.ReactiveRedisConnection.NumericResponse; import org.springframework.util.Assert; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - /** * Redis Key commands executed using reactive infrastructure. * @@ -43,6 +43,7 @@ public interface ReactiveKeyCommands { * * @param key must not be {@literal null}. * @return + * @see Redis Documentation: EXISTS */ default Mono exists(ByteBuffer key) { @@ -56,6 +57,7 @@ public interface ReactiveKeyCommands { * * @param keys must not be {@literal null}. * @return + * @see Redis Documentation: EXISTS */ Flux> exists(Publisher keys); @@ -64,6 +66,7 @@ public interface ReactiveKeyCommands { * * @param key must not be {@literal null}. * @return + * @see Redis Documentation: TYPE */ default Mono type(ByteBuffer key) { @@ -77,6 +80,7 @@ public interface ReactiveKeyCommands { * * @param keys must not be {@literal null}. * @return + * @see Redis Documentation: TYPE */ Flux> type(Publisher keys); @@ -85,6 +89,7 @@ public interface ReactiveKeyCommands { * * @param pattern must not be {@literal null}. * @return + * @see Redis Documentation: KEYS */ default Mono> keys(ByteBuffer pattern) { @@ -93,25 +98,28 @@ public interface ReactiveKeyCommands { return keys(Mono.just(pattern)).next().map(MultiValueResponse::getOutput); } - /** - * Return a random key from the keyspace. - * - * @return - */ - Mono randomKey(); - /** * Find all keys matching the given {@literal pattern}. * * @param patterns must not be {@literal null}. * @return + * @see Redis Documentation: KEYS */ Flux> keys(Publisher patterns); + /** + * Return a random key from the keyspace. + * + * @return + * @see Redis Documentation: RANDOMKEY + */ + Mono randomKey(); + /** * {@code RENAME} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: RENAME */ class RenameCommand extends KeyCommand { @@ -164,6 +172,7 @@ public interface ReactiveKeyCommands { * @param key must not be {@literal null}. * @param newName must not be {@literal null}. * @return + * @see Redis Documentation: RENAME */ default Mono rename(ByteBuffer key, ByteBuffer newName) { @@ -172,7 +181,14 @@ public interface ReactiveKeyCommands { return rename(Mono.just(RenameCommand.key(key).to(newName))).next().map(BooleanResponse::getOutput); } - Flux> rename(Publisher cmd); + /** + * Rename key {@literal oleName} to {@literal newName}. + * + * @param command must not be {@literal null}. + * @return + * @see Redis Documentation: RENAME + */ + Flux> rename(Publisher command); /** * Rename key {@literal oleName} to {@literal newName} only if {@literal newName} does not exist. @@ -180,6 +196,7 @@ public interface ReactiveKeyCommands { * @param key must not be {@literal null}. * @param newName must not be {@literal null}. * @return + * @see Redis Documentation: RENAMENX */ default Mono renameNX(ByteBuffer key, ByteBuffer newName) { @@ -193,6 +210,7 @@ public interface ReactiveKeyCommands { * * @param command must not be {@literal null}. * @return + * @see Redis Documentation: RENAMENX */ Flux> renameNX(Publisher command); @@ -201,6 +219,7 @@ public interface ReactiveKeyCommands { * * @param key must not be {@literal null}. * @return + * @see Redis Documentation: DEL */ default Mono del(ByteBuffer key) { @@ -214,6 +233,7 @@ public interface ReactiveKeyCommands { * * @param keys must not be {@literal null}. * @return {@link Flux} of {@link NumericResponse} holding the {@literal key} removed along with the deletion result. + * @see Redis Documentation: DEL */ Flux> del(Publisher keys); @@ -222,6 +242,7 @@ public interface ReactiveKeyCommands { * * @param keys must not be {@literal null}. * @return + * @see Redis Documentation: DEL */ default Mono mDel(List keys) { @@ -235,6 +256,7 @@ public interface ReactiveKeyCommands { * * @param keys must not be {@literal null}. * @return {@link Flux} of {@link NumericResponse} holding the {@literal keys} removed along with the deletion result. + * @see Redis Documentation: DEL */ Flux, Long>> mDel(Publisher> keys); } diff --git a/src/main/java/org/springframework/data/redis/connection/ReactiveListCommands.java b/src/main/java/org/springframework/data/redis/connection/ReactiveListCommands.java index a48e5bd33..e013c38ef 100644 --- a/src/main/java/org/springframework/data/redis/connection/ReactiveListCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/ReactiveListCommands.java @@ -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 reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + import java.nio.ByteBuffer; import java.time.Duration; import java.util.ArrayList; @@ -34,9 +37,6 @@ import org.springframework.data.redis.connection.RedisListCommands.Position; import org.springframework.util.Assert; import org.springframework.util.ObjectUtils; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - /** * Redis List commands executed using reactive infrastructure. * @@ -57,6 +57,8 @@ public interface ReactiveListCommands { * {@code LPUSH}/{@literal RPUSH} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: LPUSH + * @see Redis Documentation: RPUSH */ class PushCommand extends KeyCommand { @@ -167,6 +169,7 @@ public interface ReactiveListCommands { * @param key must not be {@literal null}. * @param values must not be {@literal null}. * @return + * @see Redis Documentation: RPUSH */ default Mono rPush(ByteBuffer key, List values) { @@ -182,6 +185,7 @@ public interface ReactiveListCommands { * @param key must not be {@literal null}. * @param value must not be {@literal null}. * @return + * @see Redis Documentation: RPUSHX */ default Mono rPushX(ByteBuffer key, ByteBuffer value) { @@ -197,6 +201,7 @@ public interface ReactiveListCommands { * @param key must not be {@literal null}. * @param values must not be {@literal null}. * @return + * @see Redis Documentation: LPUSH */ default Mono lPush(ByteBuffer key, List values) { @@ -212,6 +217,7 @@ public interface ReactiveListCommands { * @param key must not be {@literal null}. * @param value must not be {@literal null}. * @return + * @see Redis Documentation: LPUSHX */ default Mono lPushX(ByteBuffer key, ByteBuffer value) { @@ -226,6 +232,8 @@ public interface ReactiveListCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: LPUSH + * @see Redis Documentation: RPUSH */ Flux> push(Publisher commands); @@ -234,6 +242,7 @@ public interface ReactiveListCommands { * * @param key must not be {@literal null}. * @return + * @see Redis Documentation: LLEN */ default Mono lLen(ByteBuffer key) { @@ -247,6 +256,7 @@ public interface ReactiveListCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: LLEN */ Flux> lLen(Publisher commands); @@ -257,6 +267,7 @@ public interface ReactiveListCommands { * @param start * @param end * @return + * @see Redis Documentation: LRANGE */ default Mono> lRange(ByteBuffer key, long start, long end) { @@ -271,6 +282,7 @@ public interface ReactiveListCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: LRANGE */ Flux> lRange(Publisher commands); @@ -281,6 +293,7 @@ public interface ReactiveListCommands { * @param start * @param end * @return + * @see Redis Documentation: LTRIM */ default Mono lTrim(ByteBuffer key, long start, long end) { @@ -296,6 +309,7 @@ public interface ReactiveListCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: LTRIM */ Flux> lTrim(Publisher commands); @@ -303,6 +317,7 @@ public interface ReactiveListCommands { * {@code LINDEX} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: LINDEX */ class LIndexCommand extends KeyCommand { @@ -351,6 +366,7 @@ public interface ReactiveListCommands { * @param key must not be {@literal null}. * @param index * @return + * @see Redis Documentation: LINDEX */ default Mono lIndex(ByteBuffer key, long index) { @@ -364,6 +380,7 @@ public interface ReactiveListCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: LINDEX */ Flux> lIndex(Publisher commands); @@ -371,6 +388,7 @@ public interface ReactiveListCommands { * {@code LINSERT} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: LINSERT */ class LInsertCommand extends KeyCommand { @@ -470,6 +488,7 @@ public interface ReactiveListCommands { * @param pivot must not be {@literal null}. * @param value must not be {@literal null}. * @return + * @see Redis Documentation: LINSERT */ default Mono lInsert(ByteBuffer key, Position position, ByteBuffer pivot, ByteBuffer value) { @@ -490,6 +509,7 @@ public interface ReactiveListCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: LINSERT */ Flux> lInsert(Publisher commands); @@ -497,6 +517,7 @@ public interface ReactiveListCommands { * {@code LSET} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: LSET */ class LSetCommand extends KeyCommand { @@ -568,6 +589,7 @@ public interface ReactiveListCommands { * @param index * @param value must not be {@literal null}. * @return + * @see Redis Documentation: LSET */ default Mono lSet(ByteBuffer key, long index, ByteBuffer value) { @@ -582,6 +604,7 @@ public interface ReactiveListCommands { * * @param commands * @return + * @see Redis Documentation: LSET */ Flux> lSet(Publisher commands); @@ -589,6 +612,7 @@ public interface ReactiveListCommands { * {@code LREM} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: LREM */ class LRemCommand extends KeyCommand { @@ -679,6 +703,7 @@ public interface ReactiveListCommands { * @param key must not be {@literal null}. * @param value must not be {@literal null}. * @return + * @see Redis Documentation: LREM */ default Mono lRem(ByteBuffer key, ByteBuffer value) { @@ -695,6 +720,7 @@ public interface ReactiveListCommands { * @param count must not be {@literal null}. * @param value must not be {@literal null}. * @return + * @see Redis Documentation: LREM */ default Mono lRem(ByteBuffer key, Long count, ByteBuffer value) { @@ -712,6 +738,7 @@ public interface ReactiveListCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: LREM */ Flux> lRem(Publisher commands); @@ -719,6 +746,8 @@ public interface ReactiveListCommands { * {@code LPOP}/{@literal RPOP} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: LPOP + * @see Redis Documentation: RPOP */ class PopCommand extends KeyCommand { @@ -775,6 +804,7 @@ public interface ReactiveListCommands { * * @param key must not be {@literal null}. * @return + * @see Redis Documentation: LPOP */ default Mono lPop(ByteBuffer key) { @@ -788,6 +818,7 @@ public interface ReactiveListCommands { * * @param key must not be {@literal null}. * @return + * @see Redis Documentation: RPOP */ default Mono rPop(ByteBuffer key) { @@ -801,11 +832,15 @@ public interface ReactiveListCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: LPOP + * @see Redis Documentation: RPOP */ Flux> pop(Publisher commands); /** * @author Christoph Strobl + * @see Redis Documentation: BLPOP + * @see Redis Documentation: BRPOP */ class BPopCommand implements Command { @@ -939,6 +974,7 @@ public interface ReactiveListCommands { * @param keys must not be {@literal null}. * @param timeout must not be {@literal null}. * @return + * @see Redis Documentation: BLPOP */ default Mono blPop(List keys, Duration timeout) { @@ -955,6 +991,7 @@ public interface ReactiveListCommands { * @param keys must not be {@literal null}. * @param timeout must not be {@literal null}. * @return + * @see Redis Documentation: BRPOP */ default Mono brPop(List keys, Duration timeout) { @@ -971,6 +1008,8 @@ public interface ReactiveListCommands { * * @param commands * @return + * @see Redis Documentation: BLPOP + * @see Redis Documentation: BRPOP */ Flux bPop(Publisher commands); @@ -978,6 +1017,7 @@ public interface ReactiveListCommands { * {@code RPOPLPUSH} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: RPOPLPUSH */ class RPopLPushCommand extends KeyCommand { @@ -1030,6 +1070,7 @@ public interface ReactiveListCommands { * @param source must not be {@literal null}. * @param destination must not be {@literal null}. * @return + * @see Redis Documentation: RPOPLPUSH */ default Mono rPopLPush(ByteBuffer source, ByteBuffer destination) { @@ -1047,6 +1088,7 @@ public interface ReactiveListCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: RPOPLPUSH */ Flux> rPopLPush(Publisher commands); @@ -1054,6 +1096,7 @@ public interface ReactiveListCommands { * {@code BRPOPLPUSH} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: BRPOPLPUSH */ class BRPopLPushCommand extends KeyCommand { @@ -1130,6 +1173,7 @@ public interface ReactiveListCommands { * @param source must not be {@literal null}. * @param destination must not be {@literal null}. * @return + * @see Redis Documentation: BRPOPLPUSH */ default Mono bRPopLPush(ByteBuffer source, ByteBuffer destination, Duration timeout) { @@ -1147,6 +1191,7 @@ public interface ReactiveListCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: BRPOPLPUSH */ Flux> bRPopLPush(Publisher commands); } diff --git a/src/main/java/org/springframework/data/redis/connection/ReactiveNumberCommands.java b/src/main/java/org/springframework/data/redis/connection/ReactiveNumberCommands.java index aa2252d00..687f0bc4b 100644 --- a/src/main/java/org/springframework/data/redis/connection/ReactiveNumberCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/ReactiveNumberCommands.java @@ -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 reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + import java.nio.ByteBuffer; import org.reactivestreams.Publisher; @@ -22,9 +25,6 @@ import org.springframework.data.redis.connection.ReactiveRedisConnection.KeyComm import org.springframework.data.redis.connection.ReactiveRedisConnection.NumericResponse; import org.springframework.util.Assert; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - /** * Redis numeric commands executed using reactive infrastructure. * @@ -39,6 +39,7 @@ public interface ReactiveNumberCommands { * * @param key must not be {@literal null}. * @return + * @see Redis Documentation: INCR */ default Mono incr(ByteBuffer key) { @@ -52,6 +53,7 @@ public interface ReactiveNumberCommands { * * @param keys must not be {@literal null}. * @return + * @see Redis Documentation: INCR */ Flux> incr(Publisher keys); @@ -59,6 +61,7 @@ public interface ReactiveNumberCommands { * {@code INCRBY} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: INCRBY */ class IncrByCommand extends KeyCommand { @@ -110,6 +113,7 @@ public interface ReactiveNumberCommands { * @param key must not be {@literal null}. * @param value must not be {@literal null}. * @return + * @see Redis Documentation: INCRBY */ default Mono incrBy(ByteBuffer key, T value) { @@ -124,6 +128,7 @@ public interface ReactiveNumberCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: INCRBY */ Flux, T>> incrBy( Publisher> commands); @@ -132,6 +137,7 @@ public interface ReactiveNumberCommands { * {@code DECRBY} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: DECRBY */ class DecrByCommand extends KeyCommand { @@ -182,6 +188,7 @@ public interface ReactiveNumberCommands { * * @param key must not be {@literal null}. * @return + * @see Redis Documentation: DECR */ default Mono decr(ByteBuffer key) { @@ -195,6 +202,7 @@ public interface ReactiveNumberCommands { * * @param keys must not be {@literal null}. * @return + * @see Redis Documentation: DECR */ Flux> decr(Publisher keys); @@ -204,6 +212,7 @@ public interface ReactiveNumberCommands { * @param key must not be {@literal null}. * @param value must not be {@literal null}. * @return + * @see Redis Documentation: DECRBY */ default Mono decrBy(ByteBuffer key, T value) { @@ -225,6 +234,7 @@ public interface ReactiveNumberCommands { * {@code HINCRBY} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: HINCRBY */ class HIncrByCommand extends KeyCommand { @@ -301,6 +311,7 @@ public interface ReactiveNumberCommands { * @param field must not be {@literal null}. * @param value must not be {@literal null}. * @return + * @see Redis Documentation: HINCRBY */ default Mono hIncrBy(ByteBuffer key, ByteBuffer field, T value) { @@ -316,6 +327,7 @@ public interface ReactiveNumberCommands { * Increment {@literal value} of a hash {@literal field} by the given {@literal value}. * * @return + * @see Redis Documentation: HINCRBY */ Flux, T>> hIncrBy(Publisher> commands); diff --git a/src/main/java/org/springframework/data/redis/connection/ReactiveRedisClusterConnection.java b/src/main/java/org/springframework/data/redis/connection/ReactiveRedisClusterConnection.java index b52563561..384623da1 100644 --- a/src/main/java/org/springframework/data/redis/connection/ReactiveRedisClusterConnection.java +++ b/src/main/java/org/springframework/data/redis/connection/ReactiveRedisClusterConnection.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.springframework.data.redis.connection; /** diff --git a/src/main/java/org/springframework/data/redis/connection/ReactiveSetCommands.java b/src/main/java/org/springframework/data/redis/connection/ReactiveSetCommands.java index 89d262bcf..1b0220704 100644 --- a/src/main/java/org/springframework/data/redis/connection/ReactiveSetCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/ReactiveSetCommands.java @@ -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 reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Collection; @@ -31,9 +34,6 @@ import org.springframework.data.redis.connection.ReactiveRedisConnection.MultiVa import org.springframework.data.redis.connection.ReactiveRedisConnection.NumericResponse; import org.springframework.util.Assert; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - /** * Redis Set commands executed using reactive infrastructure. * @@ -47,6 +47,7 @@ public interface ReactiveSetCommands { * {@code SADD} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: SADD */ class SAddCommand extends KeyCommand { @@ -112,6 +113,7 @@ public interface ReactiveSetCommands { * @param key must not be {@literal null}. * @param value must not be {@literal null}. * @return + * @see Redis Documentation: SADD */ default Mono sAdd(ByteBuffer key, ByteBuffer value) { @@ -126,6 +128,7 @@ public interface ReactiveSetCommands { * @param key must not be {@literal null}. * @param values must not be {@literal null}. * @return + * @see Redis Documentation: SADD */ default Mono sAdd(ByteBuffer key, Collection values) { @@ -140,6 +143,7 @@ public interface ReactiveSetCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: SADD */ Flux> sAdd(Publisher commands); @@ -147,6 +151,7 @@ public interface ReactiveSetCommands { * {@code SREM} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: SREM */ class SRemCommand extends KeyCommand { @@ -212,6 +217,7 @@ public interface ReactiveSetCommands { * @param key must not be {@literal null}. * @param value must not be {@literal null}. * @return + * @see Redis Documentation: SREM */ default Mono sRem(ByteBuffer key, ByteBuffer value) { @@ -226,6 +232,7 @@ public interface ReactiveSetCommands { * @param key must not be {@literal null}. * @param values must not be {@literal null}. * @return + * @see Redis Documentation: SREM */ default Mono sRem(ByteBuffer key, Collection values) { @@ -240,6 +247,7 @@ public interface ReactiveSetCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: SREM */ Flux> sRem(Publisher commands); @@ -248,6 +256,7 @@ public interface ReactiveSetCommands { * * @param key must not be {@literal null}. * @return + * @see Redis Documentation: SPOP */ default Mono sPop(ByteBuffer key) { @@ -261,6 +270,7 @@ public interface ReactiveSetCommands { * * @param commands * @return + * @see Redis Documentation: SPOP */ Flux> sPop(Publisher commands); @@ -268,6 +278,7 @@ public interface ReactiveSetCommands { * {@code SMOVE} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: SMOVE */ class SMoveCommand extends KeyCommand { @@ -343,6 +354,7 @@ public interface ReactiveSetCommands { * @param destinationKey must not be {@literal null}. * @param value must not be {@literal null}. * @return + * @see Redis Documentation: SMOVE */ default Mono sMove(ByteBuffer sourceKey, ByteBuffer destinationKey, ByteBuffer value) { @@ -359,6 +371,7 @@ public interface ReactiveSetCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: SMOVE */ Flux> sMove(Publisher commands); @@ -367,6 +380,7 @@ public interface ReactiveSetCommands { * * @param key must not be {@literal null}. * @return + * @see Redis Documentation: SCARD */ default Mono sCard(ByteBuffer key) { @@ -380,6 +394,7 @@ public interface ReactiveSetCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: SCARD */ Flux> sCard(Publisher commands); @@ -387,6 +402,7 @@ public interface ReactiveSetCommands { * {@code SISMEMBER} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: SISMEMBER */ class SIsMemberCommand extends KeyCommand { @@ -439,6 +455,7 @@ public interface ReactiveSetCommands { * @param key must not be {@literal null}. * @param value must not be {@literal null}. * @return + * @see Redis Documentation: SISMEMBER */ default Mono sIsMember(ByteBuffer key, ByteBuffer value) { @@ -453,6 +470,7 @@ public interface ReactiveSetCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: SISMEMBER */ Flux> sIsMember(Publisher commands); @@ -460,6 +478,7 @@ public interface ReactiveSetCommands { * {@code SINTER} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: SINTER */ class SInterCommand implements Command { @@ -503,6 +522,7 @@ public interface ReactiveSetCommands { * * @param keys must not be {@literal null}. * @return + * @see Redis Documentation: SINTER */ default Mono> sInter(Collection keys) { @@ -516,6 +536,7 @@ public interface ReactiveSetCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: SINTER */ Flux> sInter(Publisher commands); @@ -523,6 +544,7 @@ public interface ReactiveSetCommands { * {@code SINTERSTORE} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: SINTERSTORE */ class SInterStoreCommand extends KeyCommand { @@ -576,6 +598,7 @@ public interface ReactiveSetCommands { * @param destinationKey must not be {@literal null}. * @param keys must not be {@literal null}. * @return size of set stored a {@literal destinationKey}. + * @see Redis Documentation: SINTERSTORE */ default Mono sInterStore(ByteBuffer destinationKey, Collection keys) { @@ -591,6 +614,7 @@ public interface ReactiveSetCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: SINTERSTORE */ Flux> sInterStore(Publisher commands); @@ -598,6 +622,7 @@ public interface ReactiveSetCommands { * {@code SUNION} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: SUNION */ class SUnionCommand implements Command { @@ -641,6 +666,7 @@ public interface ReactiveSetCommands { * * @param keys must not be {@literal null}. * @return + * @see Redis Documentation: SUNION */ default Mono> sUnion(Collection keys) { @@ -654,11 +680,15 @@ public interface ReactiveSetCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: SUNION */ Flux> sUnion(Publisher commands); /** + * {@code SUNIONSTORE} command parameters. + * * @author Christoph Strobl + * @see Redis Documentation: SUNIONSTORE */ class SUnionStoreCommand extends KeyCommand { @@ -712,6 +742,7 @@ public interface ReactiveSetCommands { * @param destinationKey must not be {@literal null}. * @param keys must not be {@literal null}. * @return size of set stored a {@literal destinationKey}. + * @see Redis Documentation: SUNIONSTORE */ default Mono sUnionStore(ByteBuffer destinationKey, Collection keys) { @@ -727,6 +758,7 @@ public interface ReactiveSetCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: SUNIONSTORE */ Flux> sUnionStore(Publisher commands); @@ -734,6 +766,7 @@ public interface ReactiveSetCommands { * {@code SDIFF} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: SDIFF */ class SDiffCommand implements Command { @@ -777,6 +810,7 @@ public interface ReactiveSetCommands { * * @param keys must not be {@literal null}. * @return + * @see Redis Documentation: SDIFF */ default Mono> sDiff(Collection keys) { @@ -790,6 +824,7 @@ public interface ReactiveSetCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: SDIFF */ Flux> sDiff(Publisher commands); @@ -797,6 +832,7 @@ public interface ReactiveSetCommands { * {@code SDIFFSTORE} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: SDIFFSTORE */ class SDiffStoreCommand extends KeyCommand { @@ -850,6 +886,7 @@ public interface ReactiveSetCommands { * @param destinationKey must not be {@literal null}. * @param keys must not be {@literal null}. * @return size of set stored a {@literal destinationKey}. + * @see Redis Documentation: SDIFFSTORE */ default Mono sDiffStore(ByteBuffer destinationKey, Collection keys) { @@ -865,6 +902,7 @@ public interface ReactiveSetCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: SDIFFSTORE */ Flux> sDiffStore(Publisher commands); @@ -873,6 +911,7 @@ public interface ReactiveSetCommands { * * @param key must not be {@literal null}. * @return + * @see Redis Documentation: SMEMBERS */ default Mono> sMembers(ByteBuffer key) { @@ -886,6 +925,7 @@ public interface ReactiveSetCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: SMEMBERS */ Flux> sMembers(Publisher commands); @@ -893,6 +933,7 @@ public interface ReactiveSetCommands { * {@code SRANDMEMBER} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: SRANDMEMBER */ class SRandMembersCommand extends KeyCommand { @@ -949,6 +990,7 @@ public interface ReactiveSetCommands { * * @param key must not be {@literal null}. * @return + * @see Redis Documentation: SRANDMEMBER */ default Mono sRandMember(ByteBuffer key) { return sRandMember(key, 1L).map(vals -> vals.isEmpty() ? null : vals.iterator().next()); @@ -960,6 +1002,7 @@ public interface ReactiveSetCommands { * @param key must not be {@literal null}. * @param count must not be {@literal null}. * @return + * @see Redis Documentation: SRANDMEMBER */ default Mono> sRandMember(ByteBuffer key, Long count) { @@ -975,6 +1018,7 @@ public interface ReactiveSetCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: SRANDMEMBER */ Flux> sRandMember(Publisher commands); } diff --git a/src/main/java/org/springframework/data/redis/connection/ReactiveStringCommands.java b/src/main/java/org/springframework/data/redis/connection/ReactiveStringCommands.java index 5d92b9122..e62ff6ac2 100644 --- a/src/main/java/org/springframework/data/redis/connection/ReactiveStringCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/ReactiveStringCommands.java @@ -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 reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Collection; @@ -37,9 +40,6 @@ import org.springframework.data.redis.connection.RedisStringCommands.SetOption; import org.springframework.data.redis.core.types.Expiration; import org.springframework.util.Assert; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - /** * Redis String commands executed using reactive infrastructure. * @@ -53,6 +53,7 @@ public interface ReactiveStringCommands { * {@code SET} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: SET */ class SetCommand extends KeyCommand { @@ -149,6 +150,7 @@ public interface ReactiveStringCommands { * @param key must not be {@literal null}. * @param value must not be {@literal null}. * @return + * @see Redis Documentation: SET */ default Mono set(ByteBuffer key, ByteBuffer value) { @@ -166,6 +168,7 @@ public interface ReactiveStringCommands { * @param expiration must not be {@literal null}. * @param option must not be {@literal null}. * @return + * @see Redis Documentation: SET */ default Mono set(ByteBuffer key, ByteBuffer value, Expiration expiration, SetOption option) { @@ -181,6 +184,7 @@ public interface ReactiveStringCommands { * * @param commands must not be {@literal null}. * @return {@link Flux} of {@link BooleanResponse} holding the {@link SetCommand} along with the command result. + * @see Redis Documentation: SET */ Flux> set(Publisher commands); @@ -189,6 +193,7 @@ public interface ReactiveStringCommands { * * @param key must not be {@literal null}. * @return empty {@link ByteBuffer} in case {@literal key} does not exist. + * @see Redis Documentation: GET */ default Mono get(ByteBuffer key) { @@ -203,6 +208,7 @@ public interface ReactiveStringCommands { * @param keys must not be {@literal null}. * @return {@link Flux} of {@link ByteBufferResponse} holding the {@literal key} to get along with the value * retrieved. + * @see Redis Documentation: GET */ Flux> get(Publisher keys); @@ -212,6 +218,7 @@ public interface ReactiveStringCommands { * @param key must not be {@literal null}. * @param value must not be {@literal null}. * @return + * @see Redis Documentation: GETSET */ default Mono getSet(ByteBuffer key, ByteBuffer value) { @@ -227,6 +234,7 @@ public interface ReactiveStringCommands { * @param commands must not be {@literal null}. * @return {@link Flux} of {@link ByteBufferResponse} holding the {@link SetCommand} along with the previously * existing value. + * @see Redis Documentation: GETSET */ Flux> getSet(Publisher commands); @@ -235,6 +243,7 @@ public interface ReactiveStringCommands { * * @param keys must not be {@literal null}. * @return + * @see Redis Documentation: MGET */ default Mono> mGet(List keys) { @@ -248,6 +257,7 @@ public interface ReactiveStringCommands { * * @param keysets must not be {@literal null}. * @return + * @see Redis Documentation: MGET */ Flux, ByteBuffer>> mGet(Publisher> keysets); @@ -257,6 +267,7 @@ public interface ReactiveStringCommands { * @param key must not be {@literal null}. * @param value must not be {@literal null}. * @return + * @see Redis Documentation: SETNX */ default Mono setNX(ByteBuffer key, ByteBuffer value) { @@ -271,6 +282,7 @@ public interface ReactiveStringCommands { * * @param values must not be {@literal null}. * @return + * @see Redis Documentation: SETNX */ Flux> setNX(Publisher values); @@ -281,6 +293,7 @@ public interface ReactiveStringCommands { * @param value must not be {@literal null}. * @param expireTimeout must not be {@literal null}. * @return + * @see Redis Documentation: SETEX */ default Mono setEX(ByteBuffer key, ByteBuffer value, Expiration expireTimeout) { @@ -297,6 +310,7 @@ public interface ReactiveStringCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: SETEX */ Flux> setEX(Publisher commands); @@ -307,6 +321,7 @@ public interface ReactiveStringCommands { * @param value must not be {@literal null}. * @param expireTimeout must not be {@literal null}. * @return + * @see Redis Documentation: PSETEX */ default Mono pSetEX(ByteBuffer key, ByteBuffer value, Expiration expireTimeout) { @@ -323,6 +338,7 @@ public interface ReactiveStringCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: PSETEX */ Flux> pSetEX(Publisher commands); @@ -330,6 +346,7 @@ public interface ReactiveStringCommands { * {@code MSET} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: MSET */ class MSetCommand implements Command { @@ -373,6 +390,7 @@ public interface ReactiveStringCommands { * * @param keyValuePairs must not be {@literal null}. * @return + * @see Redis Documentation: MSET */ default Mono mSet(Map keyValuePairs) { @@ -386,6 +404,7 @@ public interface ReactiveStringCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: MSET */ Flux> mSet(Publisher commands); @@ -395,6 +414,7 @@ public interface ReactiveStringCommands { * * @param keyValuePairs must not be {@literal null}. * @return + * @see Redis Documentation: MSETNX */ default Mono mSetNX(Map keyValuePairs) { @@ -409,6 +429,7 @@ public interface ReactiveStringCommands { * * @param source must not be {@literal null}. * @return + * @see Redis Documentation: MSETNX */ Flux> mSetNX(Publisher source); @@ -416,6 +437,7 @@ public interface ReactiveStringCommands { * {@code APPEND} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: APPEND */ class AppendCommand extends KeyCommand { @@ -468,6 +490,7 @@ public interface ReactiveStringCommands { * @param key must not be {@literal null}. * @param value must not be {@literal null}. * @return + * @see Redis Documentation: APPEND */ default Mono append(ByteBuffer key, ByteBuffer value) { @@ -482,6 +505,7 @@ public interface ReactiveStringCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: APPEND */ Flux> append(Publisher commands); @@ -492,6 +516,7 @@ public interface ReactiveStringCommands { * @param begin * @param end * @return + * @see Redis Documentation: GETRANGE */ default Mono getRange(ByteBuffer key, long begin, long end) { @@ -507,6 +532,7 @@ public interface ReactiveStringCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: GETRANGE */ Flux> getRange(Publisher commands); @@ -514,6 +540,7 @@ public interface ReactiveStringCommands { * {@code SETRANGE} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: SETRANGE */ class SetRangeCommand extends KeyCommand { @@ -585,6 +612,7 @@ public interface ReactiveStringCommands { * @param value must not be {@literal null}. * @param offset * @return + * @see Redis Documentation: SETRANGE */ default Mono setRange(ByteBuffer key, ByteBuffer value, long offset) { @@ -601,6 +629,7 @@ public interface ReactiveStringCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: SETRANGE */ Flux> setRange(Publisher commands); @@ -608,6 +637,7 @@ public interface ReactiveStringCommands { * {@code GETBIT} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: GETBIT */ class GetBitCommand extends KeyCommand { @@ -657,6 +687,7 @@ public interface ReactiveStringCommands { * @param key must not be {@literal null}. * @param offset * @return + * @see Redis Documentation: GETBIT */ default Mono getBit(ByteBuffer key, long offset) { @@ -670,6 +701,7 @@ public interface ReactiveStringCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: GETBIT */ Flux> getBit(Publisher commands); @@ -677,6 +709,7 @@ public interface ReactiveStringCommands { * {@code SETBIT} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: SETBIT */ class SetBitCommand extends KeyCommand { @@ -759,6 +792,7 @@ public interface ReactiveStringCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: SETBIT */ Flux> setBit(Publisher commands); @@ -766,6 +800,7 @@ public interface ReactiveStringCommands { * {@code BITCOUNT} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: BITCOUNT */ class BitCountCommand extends KeyCommand { @@ -817,6 +852,7 @@ public interface ReactiveStringCommands { * * @param key must not be {@literal null}. * @return + * @see Redis Documentation: BITCOUNT */ default Mono bitCount(ByteBuffer key) { @@ -833,6 +869,7 @@ public interface ReactiveStringCommands { * @param begin * @param end * @return + * @see Redis Documentation: BITCOUNT */ default Mono bitCount(ByteBuffer key, long begin, long end) { @@ -848,6 +885,7 @@ public interface ReactiveStringCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: BITCOUNT */ Flux> bitCount(Publisher commands); @@ -855,6 +893,7 @@ public interface ReactiveStringCommands { * {@code BITOP} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: BITOP */ class BitOpCommand { @@ -939,6 +978,7 @@ public interface ReactiveStringCommands { * @param bitOp must not be {@literal null}. * @param destination must not be {@literal null}. * @return + * @see Redis Documentation: BITOP */ default Mono bitOp(Collection keys, BitOperation bitOp, ByteBuffer destination) { @@ -956,6 +996,7 @@ public interface ReactiveStringCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: BITOP */ Flux> bitOp(Publisher commands); @@ -964,6 +1005,7 @@ public interface ReactiveStringCommands { * * @param key must not be {@literal null}. * @return + * @see Redis Documentation: STRLEN */ default Mono strLen(ByteBuffer key) { @@ -977,6 +1019,7 @@ public interface ReactiveStringCommands { * * @param keys must not be {@literal null}. * @return + * @see Redis Documentation: STRLEN */ Flux> strLen(Publisher keys); } diff --git a/src/main/java/org/springframework/data/redis/connection/ReactiveZSetCommands.java b/src/main/java/org/springframework/data/redis/connection/ReactiveZSetCommands.java index 13a64d9e0..11c0adbd1 100644 --- a/src/main/java/org/springframework/data/redis/connection/ReactiveZSetCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/ReactiveZSetCommands.java @@ -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 reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Collection; @@ -23,7 +26,6 @@ import java.util.List; import java.util.Optional; import java.util.stream.Collectors; -import com.lambdaworks.redis.Range.Boundary; import org.reactivestreams.Publisher; import org.springframework.data.domain.Range; import org.springframework.data.domain.Sort.Direction; @@ -36,9 +38,6 @@ import org.springframework.data.redis.connection.RedisZSetCommands.Tuple; import org.springframework.data.redis.util.ByteUtils; import org.springframework.util.Assert; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - /** * Redis Sorted Set commands executed using reactive infrastructure. * @@ -52,6 +51,7 @@ public interface ReactiveZSetCommands { * {@code ZADD} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: ZADD */ class ZAddCommand extends KeyCommand { @@ -185,6 +185,7 @@ public interface ReactiveZSetCommands { * @param score must not be {@literal null}. * @param value must not be {@literal null}. * @return + * @see Redis Documentation: ZADD */ default Mono zAdd(ByteBuffer key, Double score, ByteBuffer value) { @@ -202,6 +203,7 @@ public interface ReactiveZSetCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: ZADD */ Flux> zAdd(Publisher commands); @@ -209,6 +211,7 @@ public interface ReactiveZSetCommands { * {@code ZREM} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: ZREM */ class ZRemCommand extends KeyCommand { @@ -274,6 +277,7 @@ public interface ReactiveZSetCommands { * @param key must not be {@literal null}. * @param value must not be {@literal null}. * @return + * @see Redis Documentation: ZREM */ default Mono zRem(ByteBuffer key, ByteBuffer value) { @@ -288,6 +292,7 @@ public interface ReactiveZSetCommands { * @param key must not be {@literal null}. * @param values must not be {@literal null}. * @return + * @see Redis Documentation: ZREM */ default Mono zRem(ByteBuffer key, Collection values) { @@ -302,6 +307,7 @@ public interface ReactiveZSetCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: ZREM */ Flux> zRem(Publisher commands); @@ -309,6 +315,7 @@ public interface ReactiveZSetCommands { * {@code ZINCRBY} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: ZINCRBY */ class ZIncrByCommand extends KeyCommand { @@ -385,6 +392,7 @@ public interface ReactiveZSetCommands { * @param increment must not be {@literal null}. * @param value must not be {@literal null}. * @return + * @see Redis Documentation: ZINCRBY */ default Mono zIncrBy(ByteBuffer key, Number increment, ByteBuffer value) { @@ -402,6 +410,7 @@ public interface ReactiveZSetCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: ZINCRBY */ Flux> zIncrBy(Publisher commands); @@ -409,6 +418,8 @@ public interface ReactiveZSetCommands { * {@code ZRANK}/{@literal ZREVRANK} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: ZRANK + * @see Redis Documentation: ZREVRANK */ class ZRankCommand extends KeyCommand { @@ -484,6 +495,7 @@ public interface ReactiveZSetCommands { * @param key must not be {@literal null}. * @param value must not be {@literal null}. * @return + * @see Redis Documentation: ZRANK */ default Mono zRank(ByteBuffer key, ByteBuffer value) { @@ -499,6 +511,7 @@ public interface ReactiveZSetCommands { * @param key must not be {@literal null}. * @param value must not be {@literal null}. * @return + * @see Redis Documentation: ZREVRANK */ default Mono zRevRank(ByteBuffer key, ByteBuffer value) { @@ -515,6 +528,8 @@ public interface ReactiveZSetCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: ZRANK + * @see Redis Documentation: ZREVRANK */ Flux> zRank(Publisher commands); @@ -522,6 +537,8 @@ public interface ReactiveZSetCommands { * {@code ZRANGE}/{@literal ZREVRANGE} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: ZRANGE + * @see Redis Documentation: ZREVRANGE */ class ZRangeCommand extends KeyCommand { @@ -617,6 +634,7 @@ public interface ReactiveZSetCommands { * @param key must not be {@literal null}. * @param range must not be {@literal null}. * @return + * @see Redis Documentation: ZRANGE */ default Mono> zRange(ByteBuffer key, Range range) { @@ -637,6 +655,7 @@ public interface ReactiveZSetCommands { * @param key must not be {@literal null}. * @param range must not be {@literal null}. * @return + * @see Redis Documentation: ZRANGE */ default Mono> zRangeWithScores(ByteBuffer key, Range range) { @@ -652,6 +671,7 @@ public interface ReactiveZSetCommands { * @param key must not be {@literal null}. * @param range must not be {@literal null}. * @return + * @see Redis Documentation: ZREVRANGE */ default Mono> zRevRange(ByteBuffer key, Range range) { @@ -667,6 +687,7 @@ public interface ReactiveZSetCommands { * @param key must not be {@literal null}. * @param range must not be {@literal null}. * @return + * @see Redis Documentation: ZREVRANGE */ default Mono> zRevRangeWithScores(ByteBuffer key, Range range) { @@ -681,6 +702,8 @@ public interface ReactiveZSetCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: ZRANGE + * @see Redis Documentation: ZREVRANGE */ Flux> zRange(Publisher commands); @@ -688,6 +711,8 @@ public interface ReactiveZSetCommands { * {@literal ZRANGEBYSCORE}/{@literal ZREVRANGEBYSCORE}. * * @author Christoph Strobl + * @see Redis Documentation: ZRANGEBYSCORE + * @see Redis Documentation: ZREVRANGEBYSCORE */ class ZRangeByScoreCommand extends KeyCommand { @@ -803,6 +828,7 @@ public interface ReactiveZSetCommands { * @param key must not be {@literal null}. * @param range must not be {@literal null}. * @return + * @see Redis Documentation: ZRANGEBYSCORE */ default Mono> zRangeByScore(ByteBuffer key, Range range) { @@ -824,6 +850,7 @@ public interface ReactiveZSetCommands { * @param range must not be {@literal null}. * @param limit can be {@literal null}. * @return + * @see Redis Documentation: ZRANGEBYSCORE */ default Mono> zRangeByScore(ByteBuffer key, Range range, Limit limit) { @@ -844,6 +871,7 @@ public interface ReactiveZSetCommands { * @param key must not be {@literal null}. * @param range must not be {@literal null}. * @return + * @see Redis Documentation: ZRANGEBYSCORE */ default Mono> zRangeByScoreWithScores(ByteBuffer key, Range range) { @@ -861,6 +889,7 @@ public interface ReactiveZSetCommands { * @param range must not be {@literal null}. * @param limit can be {@literal null}. * @return + * @see Redis Documentation: ZRANGEBYSCORE */ default Mono> zRangeByScoreWithScores(ByteBuffer key, Range range, Limit limit) { @@ -877,6 +906,7 @@ public interface ReactiveZSetCommands { * @param key must not be {@literal null}. * @param range must not be {@literal null}. * @return + * @see Redis Documentation: ZREVRANGEBYSCORE */ default Mono> zRevRangeByScore(ByteBuffer key, Range range) { @@ -897,6 +927,7 @@ public interface ReactiveZSetCommands { * @param range must not be {@literal null}. * @param limit can be {@literal null}. * @return + * @see Redis Documentation: ZREVRANGEBYSCORE */ default Mono> zRevRangeByScore(ByteBuffer key, Range range, Limit limit) { @@ -915,6 +946,7 @@ public interface ReactiveZSetCommands { * @param key must not be {@literal null}. * @param range must not be {@literal null}. * @return + * @see Redis Documentation: ZREVRANGEBYSCORE */ default Mono> zRevRangeByScoreWithScores(ByteBuffer key, Range range) { @@ -932,6 +964,7 @@ public interface ReactiveZSetCommands { * @param range must not be {@literal null}. * @param limit can be {@literal null}. * @return + * @see Redis Documentation: ZREVRANGEBYSCORE */ default Mono> zRevRangeByScoreWithScores(ByteBuffer key, Range range, Limit limit) { @@ -948,6 +981,8 @@ public interface ReactiveZSetCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: ZRANGEBYSCORE + * @see Redis Documentation: ZREVRANGEBYSCORE */ Flux> zRangeByScore(Publisher commands); @@ -955,6 +990,7 @@ public interface ReactiveZSetCommands { * {@code ZCOUNT} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: ZCOUNT */ class ZCountCommand extends KeyCommand { @@ -1008,6 +1044,7 @@ public interface ReactiveZSetCommands { * @param key must not be {@literal null}. * @param range must not be {@literal null}. * @return + * @see Redis Documentation: ZCOUNT */ default Mono zCount(ByteBuffer key, Range range) { @@ -1024,6 +1061,7 @@ public interface ReactiveZSetCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: ZCOUNT */ Flux> zCount(Publisher commands); @@ -1032,6 +1070,7 @@ public interface ReactiveZSetCommands { * * @param key must not be {@literal null}. * @return + * @see Redis Documentation: ZCARD */ default Mono zCard(ByteBuffer key) { @@ -1045,6 +1084,7 @@ public interface ReactiveZSetCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: ZCARD */ Flux> zCard(Publisher commands); @@ -1052,6 +1092,7 @@ public interface ReactiveZSetCommands { * {@code ZSCORE} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: ZSCORE */ class ZScoreCommand extends KeyCommand { @@ -1103,6 +1144,7 @@ public interface ReactiveZSetCommands { * @param key must not be {@literal null}. * @param value must not be {@literal null}. * @return + * @see Redis Documentation: ZSCORE */ default Mono zScore(ByteBuffer key, ByteBuffer value) { @@ -1118,6 +1160,7 @@ public interface ReactiveZSetCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: ZSCORE */ Flux> zScore(Publisher commands); @@ -1125,6 +1168,7 @@ public interface ReactiveZSetCommands { * {@code ZREMRANGEBYRANK} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: ZREMRANGEBYRANK */ class ZRemRangeByRankCommand extends KeyCommand { @@ -1175,6 +1219,7 @@ public interface ReactiveZSetCommands { * @param key must not be {@literal null}. * @param range must not be {@literal null}. * @return + * @see Redis Documentation: ZREMRANGEBYRANK */ default Mono zRemRangeByRank(ByteBuffer key, Range range) { @@ -1190,6 +1235,7 @@ public interface ReactiveZSetCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: ZREMRANGEBYRANK */ Flux> zRemRangeByRank(Publisher commands); @@ -1197,6 +1243,7 @@ public interface ReactiveZSetCommands { * {@code ZREMRANGEBYSCORE} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: ZREMRANGEBYSCORE */ class ZRemRangeByScoreCommand extends KeyCommand { @@ -1245,6 +1292,7 @@ public interface ReactiveZSetCommands { * @param key must not be {@literal null}. * @param range must not be {@literal null}. * @return + * @see Redis Documentation: ZREMRANGEBYSCORE */ default Mono zRemRangeByScore(ByteBuffer key, Range range) { @@ -1260,6 +1308,7 @@ public interface ReactiveZSetCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: ZREMRANGEBYSCORE */ Flux> zRemRangeByScore(Publisher commands); @@ -1267,6 +1316,7 @@ public interface ReactiveZSetCommands { * {@code ZUNIONSTORE} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: ZUNIONSTORE */ class ZUnionStoreCommand extends KeyCommand { @@ -1358,6 +1408,7 @@ public interface ReactiveZSetCommands { * @param destinationKey must not be {@literal null}. * @param sets must not be {@literal null}. * @return + * @see Redis Documentation: ZUNIONSTORE */ default Mono zUnionStore(ByteBuffer destinationKey, List sets) { return zUnionStore(destinationKey, sets, null); @@ -1371,6 +1422,7 @@ public interface ReactiveZSetCommands { * @param sets must not be {@literal null}. * @param weights can be {@literal null}. * @return + * @see Redis Documentation: ZUNIONSTORE */ default Mono zUnionStore(ByteBuffer destinationKey, List sets, List weights) { return zUnionStore(destinationKey, sets, weights, null); @@ -1385,6 +1437,7 @@ public interface ReactiveZSetCommands { * @param weights can be {@literal null}. * @param aggregateFunction can be {@literal null}. * @return + * @see Redis Documentation: ZUNIONSTORE */ default Mono zUnionStore(ByteBuffer destinationKey, List sets, List weights, Aggregate aggregateFunction) { @@ -1403,6 +1456,7 @@ public interface ReactiveZSetCommands { * * @param commands * @return + * @see Redis Documentation: ZUNIONSTORE */ Flux> zUnionStore(Publisher commands); @@ -1410,6 +1464,7 @@ public interface ReactiveZSetCommands { * {@code ZINTERSTORE} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: ZINTERSTORE */ class ZInterStoreCommand extends KeyCommand { @@ -1502,6 +1557,7 @@ public interface ReactiveZSetCommands { * @param destinationKey must not be {@literal null}. * @param sets must not be {@literal null}. * @return + * @see Redis Documentation: ZINTERSTORE */ default Mono zInterStore(ByteBuffer destinationKey, List sets) { return zInterStore(destinationKey, sets, null); @@ -1515,6 +1571,7 @@ public interface ReactiveZSetCommands { * @param sets must not be {@literal null}. * @param weights can be {@literal null}. * @return + * @see Redis Documentation: ZINTERSTORE */ default Mono zInterStore(ByteBuffer destinationKey, List sets, List weights) { return zInterStore(destinationKey, sets, weights, null); @@ -1529,6 +1586,7 @@ public interface ReactiveZSetCommands { * @param weights can be {@literal null}. * @param aggregateFunction can be {@literal null}. * @return + * @see Redis Documentation: ZINTERSTORE */ default Mono zInterStore(ByteBuffer destinationKey, List sets, List weights, Aggregate aggregateFunction) { @@ -1547,6 +1605,7 @@ public interface ReactiveZSetCommands { * * @param commands * @return + * @see Redis Documentation: ZINTERSTORE */ Flux> zInterStore(Publisher commands); @@ -1554,6 +1613,8 @@ public interface ReactiveZSetCommands { * {@code ZRANGEBYLEX}/{@literal ZREVRANGEBYLEX} command parameters. * * @author Christoph Strobl + * @see Redis Documentation: ZRANGEBYLEX + * @see Redis Documentation: ZREVRANGEBYLEX */ class ZRangeByLexCommand extends KeyCommand { @@ -1648,6 +1709,7 @@ public interface ReactiveZSetCommands { * @param key must not be {@literal null}. * @param range must not be {@literal null}. * @return + * @see Redis Documentation: ZRANGEBYLEX */ default Mono> zRangeByLex(ByteBuffer key, Range range) { return zRangeByLex(key, range, null); @@ -1661,6 +1723,7 @@ public interface ReactiveZSetCommands { * @param range must not be {@literal null}. * @param limit can be {@literal null}. * @return + * @see Redis Documentation: ZRANGEBYLEX */ default Mono> zRangeByLex(ByteBuffer key, Range range, Limit limit) { @@ -1677,6 +1740,7 @@ public interface ReactiveZSetCommands { * @param key must not be {@literal null}. * @param range must not be {@literal null}. * @return + * @see Redis Documentation: ZREVRANGEBYLEX */ default Mono> zRevRangeByLex(ByteBuffer key, Range range) { return zRevRangeByLex(key, range, null); @@ -1690,6 +1754,7 @@ public interface ReactiveZSetCommands { * @param range must not be {@literal null}. * @param limit can be {@literal null}. * @return + * @see Redis Documentation: ZREVRANGEBYLEX */ default Mono> zRevRangeByLex(ByteBuffer key, Range range, Limit limit) { @@ -1706,6 +1771,8 @@ public interface ReactiveZSetCommands { * * @param commands must not be {@literal null}. * @return + * @see Redis Documentation: ZRANGEBYLEX + * @see Redis Documentation: ZREVRANGEBYLEX */ Flux> zRangeByLex(Publisher commands); } diff --git a/src/main/java/org/springframework/data/redis/connection/RedisClusterCommands.java b/src/main/java/org/springframework/data/redis/connection/RedisClusterCommands.java index 8fd96356e..061068f5f 100644 --- a/src/main/java/org/springframework/data/redis/connection/RedisClusterCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/RedisClusterCommands.java @@ -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 Redis Documentation: CLUSTER NODES */ Iterable clusterGetNodes(); @@ -44,6 +45,7 @@ public interface RedisClusterCommands { * * @param master must not be {@literal null}. * @return never {@literal null}. + * @see Redis Documentation: CLUSTER SLAVES */ Collection clusterGetSlaves(RedisClusterNode master); @@ -51,6 +53,7 @@ public interface RedisClusterCommands { * Retrieve information about masters and their connected slaves. * * @return never {@literal null}. + * @see Redis Documentation: CLUSTER SLAVES */ Map> clusterGetMasterSlaveMap(); @@ -59,6 +62,7 @@ public interface RedisClusterCommands { * * @param key must not be {@literal null}. * @return + * @see Redis Documentation: CLUSTER KEYSLOT */ Integer clusterGetSlotForKey(byte[] key); @@ -82,6 +86,7 @@ public interface RedisClusterCommands { * Get cluster information. * * @return + * @see Redis Documentation: CLUSTER INFO */ ClusterInfo clusterGetClusterInfo(); @@ -90,6 +95,7 @@ public interface RedisClusterCommands { * * @param node must not be {@literal null}. * @param slots + * @see Redis Documentation: CLUSTER ADDSLOTS */ 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 Redis Documentation: CLUSTER ADDSLOTS */ void clusterAddSlots(RedisClusterNode node, SlotRange range); @@ -106,6 +113,7 @@ public interface RedisClusterCommands { * * @param slot * @return + * @see Redis Documentation: CLUSTER COUNTKEYSINSLOT */ Long clusterCountKeysInSlot(int slot); @@ -114,6 +122,7 @@ public interface RedisClusterCommands { * * @param node must not be {@literal null}. * @param slots + * @see Redis Documentation: CLUSTER DELSLOTS */ 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 Redis Documentation: CLUSTER DELSLOTS */ 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 Redis Documentation: CLUSTER FORGET */ 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 Redis Documentation: CLUSTER MEET */ 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 Redis Documentation: CLUSTER SETSLOT */ 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 Redis Documentation: CLUSTER GETKEYSINSLOT */ List 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 Redis Documentation: CLUSTER REPLICATE */ void clusterReplicate(RedisClusterNode master, RedisClusterNode slave); diff --git a/src/main/java/org/springframework/data/redis/connection/RedisConnectionCommands.java b/src/main/java/org/springframework/data/redis/connection/RedisConnectionCommands.java index e20f869c4..d96fd2632 100644 --- a/src/main/java/org/springframework/data/redis/connection/RedisConnectionCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/RedisConnectionCommands.java @@ -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}. - *

- * See http://redis.io/commands/select - * - * @param dbIndex + * + * @param dbIndex the database index. + * @see Redis Documentation: SELECT */ void select(int dbIndex); /** * Returns {@code message} via server roundtrip. - *

- * See http://redis.io/commands/echo - * - * @param message + * + * @param message the message to echo. * @return + * @see Redis Documentation: ECHO */ byte[] echo(byte[] message); /** * Test connection. - *

- * See http://redis.io/commands/ping - * + * * @return Server response message - usually {@literal PONG}. + * @see Redis Documentation: PING */ String ping(); } diff --git a/src/main/java/org/springframework/data/redis/connection/RedisGeoCommands.java b/src/main/java/org/springframework/data/redis/connection/RedisGeoCommands.java index fa14be667..c60755fb2 100644 --- a/src/main/java/org/springframework/data/redis/connection/RedisGeoCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/RedisGeoCommands.java @@ -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 http://redis.io/commands/geoadd + * @see Redis Documentation: GEOADD */ 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 http://redis.io/commands/geoadd + * @see Redis Documentation: GEOADD */ Long geoAdd(byte[] key, GeoLocation 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 http://redis.io/commands/geoadd + * @see Redis Documentation: GEOADD */ Long geoAdd(byte[] key, Map 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 http://redis.io/commands/geoadd + * @see Redis Documentation: GEOADD */ Long geoAdd(byte[] key, Iterable> 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 http://redis.io/commands/geodist + * @see Redis Documentation: GEODIST */ 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 http://redis.io/commands/geodist + * @see Redis Documentation: GEODIST */ 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 http://redis.io/commands/geohash + * @see Redis Documentation: GEOHASH */ List 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 http://redis.io/commands/geopos + * @see Redis Documentation: GEOPOS */ List 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 http://redis.io/commands/georadius + * @see Redis Documentation: GEORADIUS */ GeoResults> 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 http://redis.io/commands/georadius + * @see Redis Documentation: GEORADIUS */ GeoResults> 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 http://redis.io/commands/georadiusbymember + * @see Redis Documentation: GEORADIUSBYMEMBER */ GeoResults> 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 http://redis.io/commands/georadiusbymember + * @see Redis Documentation: GEORADIUSBYMEMBER */ GeoResults> 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 http://redis.io/commands/georadiusbymember + * @see Redis Documentation: GEORADIUSBYMEMBER */ GeoResults> 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 Redis Documentation: ZREM */ Long geoRemove(byte[] key, byte[]... members); diff --git a/src/main/java/org/springframework/data/redis/connection/RedisHashCommands.java b/src/main/java/org/springframework/data/redis/connection/RedisHashCommands.java index 9d7b3e522..4e533f233 100644 --- a/src/main/java/org/springframework/data/redis/connection/RedisHashCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/RedisHashCommands.java @@ -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 Redis Documentation: HSET */ 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 Redis Documentation: HSETNX */ 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 Redis Documentation: HGET */ 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 Redis Documentation: HMGET */ List 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 Redis Documentation: HMSET */ void hMSet(byte[] key, Map 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 Redis Documentation: HINCRBY */ 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 Redis Documentation: HINCRBYFLOAT */ 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 Redis Documentation: HEXISTS */ 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 Redis Documentation: HDEL */ 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 Redis Documentation: HLEN */ 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 Redis Documentation: HKEYS? */ Set 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 Redis Documentation: HVALS */ List 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 Redis Documentation: HGETALL */ Map 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 Redis Documentation: HSCAN */ Cursor> hScan(byte[] key, ScanOptions options); } diff --git a/src/main/java/org/springframework/data/redis/connection/RedisKeyCommands.java b/src/main/java/org/springframework/data/redis/connection/RedisKeyCommands.java index a3c70a708..1f372479d 100644 --- a/src/main/java/org/springframework/data/redis/connection/RedisKeyCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/RedisKeyCommands.java @@ -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. - *

- * See http://redis.io/commands/exists - * - * @param key + * + * @param key must not be {@literal null}. * @return + * @see Redis Documentation: EXISTS */ Boolean exists(byte[] key); /** * Delete given {@code keys}. - *

- * See http://redis.io/commands/del - * - * @param keys + * + * @param keys must not be {@literal null}. * @return The number of keys that were removed. + * @see Redis Documentation: DEL */ Long del(byte[]... keys); /** * Determine the type stored at {@code key}. - *

- * See http://redis.io/commands/type - * - * @param key + * + * @param key must not be {@literal null}. * @return + * @see Redis Documentation: TYPE */ DataType type(byte[] key); /** * Find all keys matching the given {@code pattern}. - *

- * See http://redis.io/commands/keys - * - * @param pattern + * + * @param pattern must not be {@literal null}. * @return + * @see Redis Documentation: KEYS */ Set keys(byte[] pattern); /** * Use a {@link Cursor} to iterate over keys. - *

- * See http://redis.io/commands/scan - * - * @param options + * + * @param options must not be {@literal null}. * @return * @since 1.4 + * @see Redis Documentation: SCAN */ Cursor scan(ScanOptions options); /** * Return a random key from the keyspace. - *

- * See http://redis.io/commands/randomkey - * + * * @return + * @see Redis Documentation: RANDOMKEY */ byte[] randomKey(); /** - * Rename key {@code oleName} to {@code newName}. - *

- * 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 Redis Documentation: RENAME */ void rename(byte[] oldName, byte[] newName); /** - * Rename key {@code oleName} to {@code newName} only if {@code newName} does not exist. - *

- * 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 Redis Documentation: RENAMENX */ Boolean renameNX(byte[] oldName, byte[] newName); /** * Set time to live for given {@code key} in seconds. - *

- * See http://redis.io/commands/expire - * - * @param key + * + * @param key must not be {@literal null}. * @param seconds * @return + * @see Redis Documentation: EXPIRE */ Boolean expire(byte[] key, long seconds); /** * Set time to live for given {@code key} in milliseconds. - *

- * See http://redis.io/commands/pexpire - * - * @param key + * + * @param key must not be {@literal null}. * @param millis * @return + * @see Redis Documentation: PEXPIRE */ Boolean pExpire(byte[] key, long millis); /** * Set the expiration for given {@code key} as a {@literal UNIX} timestamp. - *

- * See http://redis.io/commands/expireat - * - * @param key + * + * @param key must not be {@literal null}. * @param unixTime * @return + * @see Redis Documentation: EXPIREAT */ Boolean expireAt(byte[] key, long unixTime); /** * Set the expiration for given {@code key} as a {@literal UNIX} timestamp in milliseconds. - *

- * See http://redis.io/commands/pexpireat - * - * @param key + * + * @param key must not be {@literal null}. * @param unixTimeInMillis * @return + * @see Redis Documentation: PEXPIREAT */ Boolean pExpireAt(byte[] key, long unixTimeInMillis); /** * Remove the expiration from given {@code key}. - *

- * See http://redis.io/commands/persist - * - * @param key + * + * @param key must not be {@literal null}. * @return + * @see Redis Documentation: PERSIST */ Boolean persist(byte[] key); /** * Move given {@code key} to database with {@code index}. - *

- * See http://redis.io/commands/move - * - * @param key + * + * @param key must not be {@literal null}. * @param dbIndex * @return + * @see Redis Documentation: MOVE */ Boolean move(byte[] key, int dbIndex); /** * Get the time to live for {@code key} in seconds. - *

- * See http://redis.io/commands/ttl - * - * @param key + * + * @param key must not be {@literal null}. * @return + * @see Redis Documentation: TTL */ Long ttl(byte[] key); /** * Get the time to live for {@code key} in and convert it to the given {@link TimeUnit}. - *

- * 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 Redis Documentation: TTL */ Long ttl(byte[] key, TimeUnit timeUnit); /** * Get the precise time to live for {@code key} in milliseconds. - *

- * See http://redis.io/commands/pttl - * - * @param key + * + * @param key must not be {@literal null}. * @return + * @see Redis Documentation: PTTL */ Long pTtl(byte[] key); /** * Get the precise time to live for {@code key} in and convert it to the given {@link TimeUnit}. - *

- * 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 Redis Documentation: PTTL */ Long pTtl(byte[] key, TimeUnit timeUnit); /** * Sort the elements for {@code key}. - *

- * 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 Redis Documentation: SORT */ List sort(byte[] key, SortParameters params); /** * Sort the elements for {@code key} and store result in {@code storeKey}. - *

- * 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 Redis Documentation: SORT */ Long sort(byte[] key, SortParameters params, byte[] storeKey); /** * Retrieve serialized version of the value stored at {@code key}. - *

- * See http://redis.io/commands/dump - * - * @param key + * + * @param key must not be {@literal null}. * @return + * @see Redis Documentation: DUMP */ byte[] dump(byte[] key); /** * Create {@code key} using the {@code serializedValue}, previously obtained using {@link #dump(byte[])}. - *

- * 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 Redis Documentation: RESTORE */ void restore(byte[] key, long ttlInMillis, byte[] serializedValue); } diff --git a/src/main/java/org/springframework/data/redis/connection/RedisListCommands.java b/src/main/java/org/springframework/data/redis/connection/RedisListCommands.java index 7a20c4c3a..0f4c6fe1c 100644 --- a/src/main/java/org/springframework/data/redis/connection/RedisListCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/RedisListCommands.java @@ -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}. - *

- * See http://redis.io/commands/rpush - * - * @param key + * + * @param key must not be {@literal null}. * @param values * @return + * @see Redis Documentation: RPUSH */ Long rPush(byte[] key, byte[]... values); /** * Prepend {@code values} to {@code key}. - *

- * See http://redis.io/commands/lpush - * - * @param key + * + * @param key must not be {@literal null}. * @param values * @return + * @see Redis Documentation: LPUSH */ Long lPush(byte[] key, byte[]... values); /** - * Append {@code} values to {@code key} only if the list exists. - *

- * 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 Redis Documentation: RPUSHX */ Long rPushX(byte[] key, byte[] value); /** * Prepend {@code values} to {@code key} only if the list exists. - *

- * See http://redis.io/commands/lpushx - * - * @param key + * + * @param key must not be {@literal null}. * @param value * @return + * @see Redis Documentation: LPUSHX */ Long lPushX(byte[] key, byte[] value); /** * Get the size of list stored at {@code key}. - *

- * See http://redis.io/commands/llen - * - * @param key + * + * @param key must not be {@literal null}. * @return + * @see Redis Documentation: LLEN */ Long lLen(byte[] key); /** - * Get elements between {@code begin} and {@code end} from list at {@code key}. - *

- * 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 Redis Documentation: LRANGE */ - List lRange(byte[] key, long begin, long end); + List lRange(byte[] key, long start, long end); /** - * Trim list at {@code key} to elements between {@code begin} and {@code end}. - *

- * 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 Redis Documentation: LTRIM */ - 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}. - *

- * See http://redis.io/commands/lindex - * - * @param key + * + * @param key must not be {@literal null}. * @param index * @return + * @see Redis Documentation: LINDEX */ byte[] lIndex(byte[] key, long index); /** * Insert {@code value} {@link Position#BEFORE} or {@link Position#AFTER} existing {@code pivot} for {@code key}. - *

- * 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 Redis Documentation: LINSERT */ Long lInsert(byte[] key, Position where, byte[] pivot, byte[] value); /** * Set the {@code value} list element at {@code index}. - *

- * See http://redis.io/commands/lset - * - * @param key + * + * @param key must not be {@literal null}. * @param index * @param value + * @see Redis Documentation: LSET */ void lSet(byte[] key, long index, byte[] value); /** * Removes the first {@code count} occurrences of {@code value} from the list stored at {@code key}. - *

- * See http://redis.io/commands/lrem - * - * @param key + * + * @param key must not be {@literal null}. * @param count * @param value * @return + * @see Redis Documentation: LREM */ Long lRem(byte[] key, long count, byte[] value); /** * Removes and returns first element in list stored at {@code key}. - *

- * See http://redis.io/commands/lpop - * - * @param key + * + * @param key must not be {@literal null}. * @return + * @see Redis Documentation: LPOP */ byte[] lPop(byte[] key); /** * Removes and returns last element in list stored at {@code key}. - *

- * See http://redis.io/commands/rpop - * - * @param key + * + * @param key must not be {@literal null}. * @return + * @see Redis Documentation: RPOP */ byte[] rPop(byte[] key); /** - * Removes and returns first element from lists stored at {@code keys} (see: {@link #lPop(byte[])}).
+ * Removes and returns first element from lists stored at {@code keys}.
* Blocks connection until element available or {@code timeout} reached. - *

- * See http://redis.io/commands/blpop - * + * * @param timeout - * @param keys + * @param keys must not be {@literal null}. * @return + * @see Redis Documentation: BLPOP + * @see #lPop(byte[]) */ List bLPop(int timeout, byte[]... keys); /** - * Removes and returns last element from lists stored at {@code keys} (see: {@link #rPop(byte[])}).
+ * Removes and returns last element from lists stored at {@code keys}.
* Blocks connection until element available or {@code timeout} reached. - *

- * See http://redis.io/commands/brpop - * + * * @param timeout - * @param keys + * @param keys must not be {@literal null}. * @return + * @see Redis Documentation: BRPOP + * @see #rPop(byte[]) */ List bRPop(int timeout, byte[]... keys); /** * Remove the last element from list at {@code srcKey}, append it to {@code dstKey} and return its value. - *

- * 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 Redis Documentation: RPOPLPUSH */ 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[])}).
+ * Remove the last element from list at {@code srcKey}, append it to {@code dstKey} and return its value. + *
* Blocks connection until element available or {@code timeout} reached. - *

- * 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 Redis Documentation: BRPOPLPUSH + * @see #rPopLPush(byte[], byte[]) */ byte[] bRPopLPush(int timeout, byte[] srcKey, byte[] dstKey); } diff --git a/src/main/java/org/springframework/data/redis/connection/RedisPubSubCommands.java b/src/main/java/org/springframework/data/redis/connection/RedisPubSubCommands.java index 87da53380..a435c754b 100644 --- a/src/main/java/org/springframework/data/redis/connection/RedisPubSubCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/RedisPubSubCommands.java @@ -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 Redis Documentation: PUBLISH */ Long publish(byte[] channel, byte[] message); @@ -51,8 +53,9 @@ public interface RedisPubSubCommands { *

* 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 Redis Documentation: SUBSCRIBE */ void subscribe(MessageListener listener, byte[]... channels); @@ -63,8 +66,9 @@ public interface RedisPubSubCommands { *

* 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 Redis Documentation: PSUBSCRIBE */ void pSubscribe(MessageListener listener, byte[]... patterns); } diff --git a/src/main/java/org/springframework/data/redis/connection/RedisScriptingCommands.java b/src/main/java/org/springframework/data/redis/connection/RedisScriptingCommands.java index 0f22e6217..48614c58a 100644 --- a/src/main/java/org/springframework/data/redis/connection/RedisScriptingCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/RedisScriptingCommands.java @@ -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. - *

- * See http://redis.io/commands/script-flush + * + * @see Redis Documentation: SCRIPT FLUSH */ void scriptFlush(); /** * Kill current lua script execution. - *

- * See http://redis.io/commands/script-kill + * + * @see Redis Documentation: SCRIPT KILL */ void scriptKill(); /** * Load lua script into scripts cache, without executing it.
- * Execute the script by calling {@link #evalSha(String, ReturnType, int, byte[])}. - *

- * 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 Redis Documentation: SCRIPT LOAD */ String scriptLoad(byte[] script); /** * Check if given {@code scriptShas} exist in script cache. - *

- * See http://redis.io/commands/script-exits - * + * * @param scriptShas * @return one entry per given scriptSha in returned list. + * @see Redis Documentation: SCRIPT EXISTS */ List scriptExists(String... scriptShas); /** * Evaluate given {@code script}. - *

- * 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 Redis Documentation: EVAL */ T eval(byte[] script, ReturnType returnType, int numKeys, byte[]... keysAndArgs); /** * Evaluate given {@code scriptSha}. - *

- * 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 Redis Documentation: EVALSHA */ T evalSha(String scriptSha, ReturnType returnType, int numKeys, byte[]... keysAndArgs); /** * Evaluate given {@code scriptSha}. - *

- * 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 Redis Documentation: EVALSHA */ T evalSha(byte[] scriptSha, ReturnType returnType, int numKeys, byte[]... keysAndArgs); } diff --git a/src/main/java/org/springframework/data/redis/connection/RedisSentinelCommands.java b/src/main/java/org/springframework/data/redis/connection/RedisSentinelCommands.java index 0fcc40f61..7e8009002 100644 --- a/src/main/java/org/springframework/data/redis/connection/RedisSentinelCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/RedisSentinelCommands.java @@ -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 Redis Sentinel Documentation */ public interface RedisSentinelCommands { diff --git a/src/main/java/org/springframework/data/redis/connection/RedisServerCommands.java b/src/main/java/org/springframework/data/redis/connection/RedisServerCommands.java index 6c35ef54d..fe9e3f269 100644 --- a/src/main/java/org/springframework/data/redis/connection/RedisServerCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/RedisServerCommands.java @@ -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. - *

- * See http://redis.io/commands/bgrewriteaof * * @deprecated As of 1.3, use {@link #bgReWriteAof}. + * @see Redis Documentation: BGREWRITEAOF */ @Deprecated void bgWriteAof(); /** * Start an {@literal Append Only File} rewrite process on server. - *

- * See http://redis.io/commands/bgrewriteaof - * + * * @since 1.3 + * @see Redis Documentation: BGREWRITEAOF */ void bgReWriteAof(); /** * Start background saving of db on server. - *

- * See http://redis.io/commands/bgsave + * + * @see Redis Documentation: BGSAVE */ void bgSave(); /** * Get time of last {@link #bgSave()} operation in seconds. - *

- * See http://redis.io/commands/lastsave - * + * * @return + * @see Redis Documentation: LASTSAVE */ Long lastSave(); /** * Synchronous save current db snapshot on server. - *

- * See http://redis.io/commands/save + * + * @see Redis Documentation: SAVE */ void save(); /** * Get the total number of available keys in currently selected database. - *

- * See http://redis.io/commands/dbsize - * + * * @return + * @see Redis Documentation: DBSIZE */ Long dbSize(); /** * Delete all keys of the currently selected database. - *

- * See http://redis.io/commands/flushdb + * + * @see Redis Documentation: FLUSHDB */ void flushDb(); /** * Delete all all keys from all databases. - *

- * See http://redis.io/commands/flushall + * + * @see Redis Documentation: FLUSHALL */ void flushAll(); /** * Load {@literal default} server information like *

    - *
  • mempory
  • + *
  • memory
  • *
  • cpu utilization
  • *
  • replication
  • *
*

- * See http://redis.io/commands/info * * @return + * @see Redis Documentation: INFO */ Properties info(); /** * Load server information for given {@code selection}. - *

- * See http://redis.io/commands/info - * + * * @return + * @see Redis Documentation: INFO */ Properties info(String section); /** * Shutdown server. - *

- * See http://redis.io/commands/shutdown + * + * @see Redis Documentation: SHUTDOWN */ void shutdown(); /** * Shutdown server. - *

- * See http://redis.io/commands/shutdown - * + * + * @see Redis Documentation: SHUTDOWN * @since 1.3 */ void shutdown(ShutdownOption option); /** * Load configuration parameters for given {@code pattern} from server. - *

- * See http://redis.io/commands/config-get - * + * * @param pattern * @return + * @see Redis Documentation: CONFIG GET */ List getConfig(String pattern); /** * Set server configuration for {@code param} to {@code value}. - *

- * See http://redis.io/commands/config-set - * + * * @param param * @param value + * @see Redis Documentation: CONFIG SET */ void setConfig(String param, String value); /** * Reset statistic counters on server.
* Counters can be retrieved using {@link #info()}. - *

- * See http://redis.io/commands/config-resetstat + * + * @see Redis Documentation: CONFIG RESETSTAT */ void resetConfigStats(); @@ -177,6 +170,7 @@ public interface RedisServerCommands { * * @return current server time in milliseconds. * @since 1.1 + * @see Redis Documentation: TIME */ 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 Redis Documentation: CLIENT KILL */ void killClient(String host, int port); @@ -194,14 +189,14 @@ public interface RedisServerCommands { * * @param name * @since 1.3 + * @see Redis Documentation: CLIENT SETNAME */ void setClientName(byte[] name); /** * Returns the name of the current connection. - *

- * See http://redis.io/commands/client-getname - * + * + * @see Redis Documentation: CLIENT GETNAME * @return * @since 1.3 */ @@ -209,50 +204,55 @@ public interface RedisServerCommands { /** * Request information and statistics about connected clients. - *

- * See http://redis.io/commands/client-list - * + * * @return {@link List} of {@link RedisClientInfo} objects. * @since 1.3 + * @see Redis Documentation: CLIENT LIST */ List getClientList(); /** * Change redis replication setting to new master. - *

- * See http://redis.io/commands/slaveof - * - * @param host + * + * @param host must not be {@literal null}. * @param port * @since 1.3 + * @see Redis Documentation: SLAVEOF */ void slaveOf(String host, int port); /** * Change server into master. - *

- * See http://redis.io/commands/slaveof - * + * * @since 1.3 + * @see Redis Documentation: SLAVEOF */ 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 Redis Documentation: MIGRATE */ 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 Redis Documentation: MIGRATE */ void migrate(byte[] key, RedisNode target, int dbIndex, MigrateOption option, long timeout); } diff --git a/src/main/java/org/springframework/data/redis/connection/RedisSetCommands.java b/src/main/java/org/springframework/data/redis/connection/RedisSetCommands.java index 7768e4dd5..818ff5e27 100644 --- a/src/main/java/org/springframework/data/redis/connection/RedisSetCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/RedisSetCommands.java @@ -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}. - *

- * See http://redis.io/commands/sadd - * - * @param key + * + * @param key must not be {@literal null}. * @param values * @return + * @see Redis Documentation: SADD */ Long sAdd(byte[] key, byte[]... values); /** * Remove given {@code values} from set at {@code key} and return the number of removed elements. - *

- * See http://redis.io/commands/srem - * - * @param key + * + * @param key must not be {@literal null}. * @param values * @return + * @see Redis Documentation: SREM */ Long sRem(byte[] key, byte[]... values); /** * Remove and return a random member from set at {@code key}. - *

- * See http://redis.io/commands/spop - * - * @param key + * + * @param key must not be {@literal null}. * @return + * @see Redis Documentation: SPOP */ byte[] sPop(byte[] key); /** * Move {@code value} from {@code srcKey} to {@code destKey} - *

- * 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 Redis Documentation: SMOVE */ Boolean sMove(byte[] srcKey, byte[] destKey, byte[] value); /** * Get size of set at {@code key}. - *

- * See http://redis.io/commands/scard - * - * @param key + * + * @param key must not be {@literal null}. * @return + * @see Redis Documentation: SCARD */ Long sCard(byte[] key); /** * Check if set at {@code key} contains {@code value}. - *

- * See http://redis.io/commands/sismember - * - * @param key + * + * @param key must not be {@literal null}. * @param value * @return + * @see Redis Documentation: SISMEMBER */ Boolean sIsMember(byte[] key, byte[] value); /** * Returns the members intersecting all given sets at {@code keys}. - *

- * See http://redis.io/commands/sinter - * - * @param keys + * + * @param keys must not be {@literal null}. * @return + * @see Redis Documentation: SINTER */ Set sInter(byte[]... keys); /** * Intersect all given sets at {@code keys} and store result in {@code destKey}. - *

- * 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 Redis Documentation: SINTERSTORE */ Long sInterStore(byte[] destKey, byte[]... keys); /** * Union all sets at given {@code keys}. - *

- * See http://redis.io/commands/sunion - * - * @param keys + * + * @param keys must not be {@literal null}. * @return + * @see Redis Documentation: SUNION */ Set sUnion(byte[]... keys); /** * Union all sets at given {@code keys} and store result in {@code destKey}. - *

- * 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 Redis Documentation: SUNIONSTORE */ Long sUnionStore(byte[] destKey, byte[]... keys); /** * Diff all sets for given {@code keys}. - *

- * See http://redis.io/commands/sdiff - * - * @param keys + * + * @param keys must not be {@literal null}. * @return + * @see Redis Documentation: SDIFF */ Set sDiff(byte[]... keys); /** - * Diff all sets for given {@code keys} and store result in {@code destKey} - *

- * 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 Redis Documentation: SDIFFSTORE */ Long sDiffStore(byte[] destKey, byte[]... keys); /** * Get all elements of set at {@code key}. - *

- * See http://redis.io/commands/smembers - * - * @param key + * + * @param key must not be {@literal null}. * @return + * @see Redis Documentation: SMEMBERS */ Set sMembers(byte[] key); /** * Get random element from set at {@code key}. - *

- * See http://redis.io/commands/srandmember - * - * @param key + * + * @param key must not be {@literal null}. * @return + * @see Redis Documentation: SRANDMEMBER */ byte[] sRandMember(byte[] key); /** * Get {@code count} random elements from set at {@code key}. - *

- * See http://redis.io/commands/srandmember - * - * @param key + * + * @param key must not be {@literal null}. * @param count * @return + * @see Redis Documentation: SRANDMEMBER */ List sRandMember(byte[] key, long count); /** * Use a {@link Cursor} to iterate over elements in set at {@code key}. - *

- * 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 Redis Documentation: SCAN */ Cursor sScan(byte[] key, ScanOptions options); } diff --git a/src/main/java/org/springframework/data/redis/connection/RedisStringCommands.java b/src/main/java/org/springframework/data/redis/connection/RedisStringCommands.java index b782c7966..3e7bda6a6 100644 --- a/src/main/java/org/springframework/data/redis/connection/RedisStringCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/RedisStringCommands.java @@ -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}. - *

- * See http://redis.io/commands/get - * + * * @param key must not be {@literal null}. * @return + * @see Redis Documentation: GET */ byte[] get(byte[] key); /** - * Set value of {@code key} and return its old value. - *

- * 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 Redis Documentation: GETSET */ byte[] getSet(byte[] key, byte[] value); /** - * Get the values of all given {@code keys}. - *

- * 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 Redis Documentation: MGET */ List mGet(byte[]... keys); /** * Set {@code value} for {@code key}. - *

- * See http://redis.io/commands/set - * + * * @param key must not be {@literal null}. * @param value must not be {@literal null}. + * @see Redis Documentation: SET */ 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}. - *

- * 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 Redis Documentation: SET */ void set(byte[] key, byte[] value, Expiration expiration, SetOption option); /** * Set {@code value} for {@code key}, only if {@code key} does not exist. - *

- * See http://redis.io/commands/setnx - * + * * @param key must not be {@literal null}. * @param value must not be {@literal null}. * @return + * @see Redis Documentation: SETNX */ Boolean setNX(byte[] key, byte[] value); /** * Set the {@code value} and expiration in {@code seconds} for {@code key}. - *

- * See http://redis.io/commands/setex - * + * * @param key must not be {@literal null}. * @param seconds * @param value must not be {@literal null}. + * @see Redis Documentation: SETEX */ void setEx(byte[] key, long seconds, byte[] value); /** * Set the {@code value} and expiration in {@code milliseconds} for {@code key}. - *

- * 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 Redis Documentation: PSETEX */ void pSetEx(byte[] key, long milliseconds, byte[] value); /** * Set multiple keys to multiple values using key-value pairs provided in {@code tuple}. - *

- * See http://redis.io/commands/mset - * - * @param tuple + * + * @param tuple must not be {@literal null}. + * @see Redis Documentation: MSET */ void mSet(Map tuple); /** * Set multiple keys to multiple values using key-value pairs provided in {@code tuple} only if the provided key does * not exist. - *

- * See http://redis.io/commands/msetnx - * - * @param tuple + * + * @param tuple must not be {@literal null}. + * @see Redis Documentation: MSETNX */ Boolean mSetNX(Map tuple); /** - * Increment value of {@code key} by 1. - *

- * 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 Redis Documentation: INCR */ Long incr(byte[] key); /** - * Increment value of {@code key} by {@code value}. - *

- * 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 Redis Documentation: INCRBY */ Long incrBy(byte[] key, long value); /** - * Increment value of {@code key} by {@code value}. - *

- * 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 Redis Documentation: INCRBYFLOAT */ Double incrBy(byte[] key, double value); /** - * Decrement value of {@code key} by 1. - *

- * 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 Redis Documentation: DECR */ Long decr(byte[] key); /** - * Increment value of {@code key} by {@code value}. - *

- * 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 Redis Documentation: DECRBY */ Long decrBy(byte[] key, long value); /** * Append a {@code value} to {@code key}. - *

- * See http://redis.io/commands/append - * + * * @param key must not be {@literal null}. * @param value * @return + * @see Redis Documentation: APPEND */ Long append(byte[] key, byte[] value); /** * Get a substring of value of {@code key} between {@code begin} and {@code end}. - *

- * See http://redis.io/commands/getrange - * + * * @param key must not be {@literal null}. * @param begin * @param end * @return + * @see Redis Documentation: GETRANGE */ byte[] getRange(byte[] key, long begin, long end); /** * Overwrite parts of {@code key} starting at the specified {@code offset} with given {@code value}. - *

- * See http://redis.io/commands/setrange - * + * * @param key must not be {@literal null}. * @param value * @param offset + * @see Redis Documentation: SETRANGE */ void setRange(byte[] key, byte[] value, long offset); /** * Get the bit value at {@code offset} of value at {@code key}. - *

- * See http://redis.io/commands/getbit - * + * * @param key must not be {@literal null}. * @param offset * @return + * @see Redis Documentation: GETBIT */ Boolean getBit(byte[] key, long offset); /** * Sets the bit at {@code offset} in value stored at {@code key}. - *

- * See http://redis.io/commands/setbit - * + * * @param key must not be {@literal null}. * @param offset * @param value * @return the original bit value stored at {@code offset}. + * @see Redis Documentation: SETBIT */ Boolean setBit(byte[] key, long offset, boolean value); /** * Count the number of set bits (population counting) in value stored at {@code key}. - *

- * See http://redis.io/commands/bitcount - * + * * @param key must not be {@literal null}. * @return + * @see Redis Documentation: BITCOUNT */ Long bitCount(byte[] key); /** * Count the number of set bits (population counting) of value stored at {@code key} between {@code begin} and * {@code end}. - *

- * See http://redis.io/commands/bitcount - * + * * @param key must not be {@literal null}. * @param begin * @param end * @return + * @see Redis Documentation: BITCOUNT */ Long bitCount(byte[] key, long begin, long end); /** * Perform bitwise operations between strings. - *

- * 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 Redis Documentation: BITOP */ Long bitOp(BitOperation op, byte[] destination, byte[]... keys); /** * Get the length of the value stored at {@code key}. - *

- * See http://redis.io/commands/strlen - * + * * @param key must not be {@literal null}. * @return + * @see Redis Documentation: STRLEN */ Long strLen(byte[] key); diff --git a/src/main/java/org/springframework/data/redis/connection/RedisTxCommands.java b/src/main/java/org/springframework/data/redis/connection/RedisTxCommands.java index 2426d5284..8725f9e3a 100644 --- a/src/main/java/org/springframework/data/redis/connection/RedisTxCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/RedisTxCommands.java @@ -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.
* Commands will be queued and can then be executed by calling {@link #exec()} or rolled back using {@link #discard()} *

- * See http://redis.io/commands/multi + * + * @see Redis Documentation: MULTI */ void multi(); /** * Executes all queued commands in a transaction started with {@link #multi()}.
- * If used along with {@link #watch(byte[])} the operation will fail if any of watched keys has been modified. - *

- * 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 Redis Documentation: EXEC */ List exec(); /** * Discard all commands issued after {@link #multi()}. - *

- * See http://redis.io/commands/discard + * + * @see Redis Documentation: DISCARD */ void discard(); /** * Watch given {@code keys} for modifications during transaction started with {@link #multi()}. - *

- * See http://redis.io/commands/watch - * - * @param keys + * + * @param keys must not be {@literal null}. + * @see Redis Documentation: WATCH */ void watch(byte[]... keys); /** - * Flushes all the previously {@link #watch(byte[])} keys. - *

- * See http://redis.io/commands/unwatch + * Flushes all the previously {@link #watch(byte[]...)} keys. + * + * @see Redis Documentation: UNWATCH */ void unwatch(); } diff --git a/src/main/java/org/springframework/data/redis/connection/RedisZSetCommands.java b/src/main/java/org/springframework/data/redis/connection/RedisZSetCommands.java index 35ef742a6..7f872dd34 100644 --- a/src/main/java/org/springframework/data/redis/connection/RedisZSetCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/RedisZSetCommands.java @@ -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. - *

- * 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 Redis Documentation: ZADD */ 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. - *

- * 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 Redis Documentation: ZADD */ Long zAdd(byte[] key, Set tuples); /** * Remove {@code values} from sorted set. Return number of removed elements. - *

- * 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 Redis Documentation: ZREM */ Long zRem(byte[] key, byte[]... values); /** * Increment the score of element with {@code value} in sorted set by {@code increment}. - *

- * 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 Redis Documentation: ZINCRBY */ Double zIncrBy(byte[] key, double increment, byte[] value); /** * Determine the index of element with {@code value} in a sorted set. - *

- * See http://redis.io/commands/zrank - * - * @param key - * @param value + * + * @param key must not be {@literal null}. + * @param value the value. * @return + * @see Redis Documentation: ZRANK */ Long zRank(byte[] key, byte[] value); /** * Determine the index of element with {@code value} in a sorted set when scored high to low. - *

- * See http://redis.io/commands/zrevrank - * - * @param key - * @param value + * + * @param key must not be {@literal null}. + * @param value the value. * @return + * @see Redis Documentation: ZREVRANK */ Long zRevRank(byte[] key, byte[] value); /** - * Get elements between {@code begin} and {@code end} from sorted set. - *

- * 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 Redis Documentation: ZRANGE */ - Set zRange(byte[] key, long begin, long end); + Set zRange(byte[] key, long start, long end); /** - * Get set of {@link Tuple}s between {@code begin} and {@code end} from sorted set. - *

- * 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 Redis Documentation: ZRANGE */ - Set zRangeWithScores(byte[] key, long begin, long end); + Set zRangeWithScores(byte[] key, long start, long end); /** * Get elements where score is between {@code min} and {@code max} from sorted set. - *

- * See http://redis.io/commands/zrangebyscore - * - * @param key + * + * @param key must not be {@literal null}. * @param min * @param max * @return + * @see Redis Documentation: ZRANGEBYSCORE */ Set 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 Redis Documentation: ZRANGEBYSCORE */ Set zRangeByScoreWithScores(byte[] key, Range range); /** * Get set of {@link Tuple}s where score is between {@code min} and {@code max} from sorted set. - *

- * See http://redis.io/commands/zrangebyscore - * - * @param key + * + * @param key must not be {@literal null}. * @param min * @param max * @return + * @see Redis Documentation: ZRANGEBYSCORE */ Set 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. - *

- * 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 Redis Documentation: ZRANGEBYSCORE */ Set 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. - *

- * See http://redis.io/commands/zrangebyscore - * + * * @param key * @param min * @param max * @param offset * @param count * @return + * @see Redis Documentation: ZRANGEBYSCORE */ Set 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 Redis Documentation: ZRANGEBYSCORE */ Set 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. - *

- * 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 Redis Documentation: ZREVRANGE */ - Set zRevRange(byte[] key, long begin, long end); + Set 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. - *

- * 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 Redis Documentation: ZREVRANGE */ - Set zRevRangeWithScores(byte[] key, long begin, long end); + Set 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. - *

- * See http://redis.io/commands/zrevrange - * - * @param key + * + * @param key must not be {@literal null}. * @param min * @param max * @return + * @see Redis Documentation: ZREVRANGE */ Set 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 Redis Documentation: ZREVRANGEBYSCORE */ Set 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. - *

- * See http://redis.io/commands/zrevrange - * - * @param key + * + * @param key must not be {@literal null}. * @param min * @param max * @return + * @see Redis Documentation: ZREVRANGEBYSCORE */ Set 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. - *

- * 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 Redis Documentation: ZREVRANGEBYSCORE */ Set 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 Redis Documentation: ZREVRANGEBYSCORE */ Set 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. - *

- * 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 Redis Documentation: ZREVRANGEBYSCORE */ Set 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 Redis Documentation: ZREVRANGEBYSCORE */ Set 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 Redis Documentation: ZREVRANGEBYSCORE */ Set zRevRangeByScoreWithScores(byte[] key, Range range, Limit limit); /** * Count number of elements within sorted set with scores between {@code min} and {@code max}. - *

- * See http://redis.io/commands/zcount - * - * @param key + * + * @param key must not be {@literal null}. * @param min * @param max * @return + * @see Redis Documentation: ZCOUNT */ 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 Redis Documentation: ZCOUNT */ Long zCount(byte[] key, Range range); /** * Get the size of sorted set with {@code key}. - *

- * See http://redis.io/commands/zcard - * - * @param key + * + * @param key must not be {@literal null}. * @return + * @see Redis Documentation: ZCARD */ Long zCard(byte[] key); /** * Get the score of element with {@code value} from sorted set with key {@code key}. - *

- * See http://redis.io/commands/zrem * - * @param key - * @param value + * @param key must not be {@literal null}. + * @param value the value. * @return + * @see Redis Documentation: ZREM */ Double zScore(byte[] key, byte[] value); /** - * Remove elements in range between {@code begin} and {@code end} from sorted set with {@code key}. - *

- * 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 Redis Documentation: ZREMRANGEBYRANK */ - 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}. - *

- * See http://redis.io/commands/zremrangebyscore - * - * @param key + * + * @param key must not be {@literal null}. * @param min * @param max * @return + * @see Redis Documentation: ZREMRANGEBYSCORE */ 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 Redis Documentation: ZREMRANGEBYSCORE */ Long zRemRangeByScore(byte[] key, Range range); /** * Union sorted {@code sets} and store result in destination {@code key}. - *

- * 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 Redis Documentation: ZUNIONSTORE */ Long zUnionStore(byte[] destKey, byte[]... sets); /** * Union sorted {@code sets} and store result in destination {@code key}. - *

- * 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 Redis Documentation: ZUNIONSTORE */ Long zUnionStore(byte[] destKey, Aggregate aggregate, int[] weights, byte[]... sets); /** * Intersect sorted {@code sets} and store result in destination {@code key}. - *

- * 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 Redis Documentation: ZINTERSTORE */ Long zInterStore(byte[] destKey, byte[]... sets); /** * Intersect sorted {@code sets} and store result in destination {@code key}. - *

- * 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 Redis Documentation: ZINTERSTORE */ Long zInterStore(byte[] destKey, Aggregate aggregate, int[] weights, byte[]... sets); /** * Use a {@link Cursor} to iterate over elements in sorted set at {@code key}. - *

- * 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 Redis Documentation: ZSCAN */ Cursor zScan(byte[] key, ScanOptions options); /** * Get elements where score is between {@code min} and {@code max} from sorted set. - *

- * 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 Redis Documentation: ZRANGEBYSCORE */ Set 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 Redis Documentation: ZRANGEBYSCORE */ Set 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. - *

- * 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 Redis Documentation: ZRANGEBYSCORE */ Set 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 Redis Documentation: ZRANGEBYSCORE */ Set 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 Redis Documentation: ZRANGEBYLEX */ Set 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 Redis Documentation: ZRANGEBYLEX */ Set 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 Redis Documentation: ZRANGEBYLEX */ Set zRangeByLex(byte[] key, Range range, Limit limit); diff --git a/src/main/java/org/springframework/data/redis/connection/StringRedisConnection.java b/src/main/java/org/springframework/data/redis/connection/StringRedisConnection.java index 7b2aab8e6..e9f6208db 100644 --- a/src/main/java/org/springframework/data/redis/connection/StringRedisConnection.java +++ b/src/main/java/org/springframework/data/redis/connection/StringRedisConnection.java @@ -1,5 +1,5 @@ /* - * Copyright 2011-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. @@ -57,765 +57,1525 @@ public interface StringRedisConnection extends RedisConnection { String getValueAsString(); } + /** + * 'Native' or 'raw' execution of the given command along-side the given arguments. The command is executed as is, + * with as little 'interpretation' as possible - it is up to the caller to take care of any processing of arguments or + * the result. + * + * @param command Command to execute + * @param args Possible command arguments (may be null) + * @return execution result. + * @see RedisCommands#execute(String, byte[]...) + */ Object execute(String command, String... args); + /** + * 'Native' or 'raw' execution of the given command along-side the given arguments. The command is executed as is, + * with as little 'interpretation' as possible - it is up to the caller to take care of any processing of arguments or + * the result. + * + * @param command Command to execute + * @return execution result. + * @see RedisCommands#execute(String, byte[]...) + */ Object execute(String command); /** * Determine if given {@code key} exists. - *

- * See http://redis.io/commands/exists * - * @param key + * @param key must not be {@literal null}. * @return + * @see Redis Documentation: EXISTS + * @see RedisKeyCommands#exists(byte[]) */ Boolean exists(String key); /** * Delete given {@code keys}. - *

- * See http://redis.io/commands/del * - * @param keys + * @param keys must not be {@literal null}. * @return The number of keys that were removed. + * @see Redis Documentation: DEL + * @see RedisKeyCommands#del(byte[]...) */ Long del(String... keys); /** * Determine the type stored at {@code key}. - *

- * See http://redis.io/commands/type * - * @param key + * @param key must not be {@literal null}. * @return + * @see Redis Documentation: TYPE + * @see RedisKeyCommands#type(byte[]) */ DataType type(String key); /** * Find all keys matching the given {@code pattern}. - *

- * See http://redis.io/commands/keys * - * @param pattern + * @param pattern must not be {@literal null}. * @return + * @see Redis Documentation: KEYS + * @see RedisKeyCommands#keys(byte[]) */ Collection keys(String pattern); /** * Rename key {@code oleName} to {@code newName}. - *

- * See http://redis.io/commands/rename * - * @param oldName - * @param newName + * @param oldName must not be {@literal null}. + * @param newName must not be {@literal null}. + * @see Redis Documentation: RENAME + * @see RedisKeyCommands#rename(byte[], byte[]) */ void rename(String oldName, String newName); /** * Rename key {@code oleName} to {@code newName} only if {@code newName} does not exist. - *

- * See http://redis.io/commands/renamenx * - * @param oldName - * @param newName + * @param oldName must not be {@literal null}. + * @param newName must not be {@literal null}. * @return + * @see Redis Documentation: RENAMENX + * @see RedisKeyCommands#renameNX(byte[], byte[]) */ Boolean renameNX(String oldName, String newName); /** * Set time to live for given {@code key} in seconds. - *

- * See http://redis.io/commands/expire * - * @param key + * @param key must not be {@literal null}. * @param seconds * @return + * @see Redis Documentation: EXPIRE + * @see RedisKeyCommands#expire(byte[], long) */ Boolean expire(String key, long seconds); /** * Set time to live for given {@code key} in milliseconds. - *

- * See http://redis.io/commands/pexpire * - * @param key + * @param key must not be {@literal null}. * @param millis * @return + * @see Redis Documentation: PEXPIRE + * @see RedisKeyCommands#pExpire(byte[], long) */ Boolean pExpire(String key, long millis); /** * Set the expiration for given {@code key} as a {@literal UNIX} timestamp. - *

- * See http://redis.io/commands/expireat * - * @param key + * @param key must not be {@literal null}. * @param unixTime * @return + * @see Redis Documentation: EXPIREAT + * @see RedisKeyCommands#expireAt(byte[], long) */ Boolean expireAt(String key, long unixTime); /** * Set the expiration for given {@code key} as a {@literal UNIX} timestamp in milliseconds. - *

- * See http://redis.io/commands/pexpireat * - * @param key + * @param key must not be {@literal null}. * @param unixTimeInMillis * @return + * @see Redis Documentation: PEXPIREAT + * @see RedisKeyCommands#pExpireAt(byte[], long) */ Boolean pExpireAt(String key, long unixTimeInMillis); /** * Remove the expiration from given {@code key}. - *

- * See http://redis.io/commands/persist * - * @param key + * @param key must not be {@literal null}. * @return + * @see Redis Documentation: PERSIST + * @see RedisKeyCommands#persist(byte[]) */ Boolean persist(String key); /** * Move given {@code key} to database with {@code index}. - *

- * See http://redis.io/commands/move * - * @param key + * @param key must not be {@literal null}. * @param dbIndex * @return + * @see Redis Documentation: MOVE + * @see RedisKeyCommands#move(byte[], int) */ Boolean move(String key, int dbIndex); /** * Get the time to live for {@code key} in seconds. - *

- * See http://redis.io/commands/ttl * - * @param key + * @param key must not be {@literal null}. * @return + * @see Redis Documentation: TTL + * @see RedisKeyCommands#ttl(byte[]) */ Long ttl(String key); /** * Get the time to live for {@code key} in and convert it to the given {@link TimeUnit}. - *

- * 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 Redis Documentation: TTL + * @see RedisKeyCommands#ttl(byte[], TimeUnit) */ Long ttl(String key, TimeUnit timeUnit); /** * Get the precise time to live for {@code key} in milliseconds. - *

- * See http://redis.io/commands/pttl * - * @param key + * @param key must not be {@literal null}. * @return + * @see Redis Documentation: PTTL + * @see RedisKeyCommands#pTtl(byte[]) */ Long pTtl(String key); /** * Get the precise time to live for {@code key} in and convert it to the given {@link TimeUnit}. - *

- * 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 Redis Documentation: PTTL + * @see RedisKeyCommands#pTtl(byte[], TimeUnit) */ Long pTtl(String key, TimeUnit timeUnit); + /** + * Returns {@code message} via server roundtrip. + * + * @param message the message to echo. + * @return + * @see Redis Documentation: ECHO + * @see RedisConnectionCommands#echo(byte[]) + */ String echo(String message); - // sort commands + /** + * Sort the elements for {@code key}. + * + * @param key must not be {@literal null}. + * @param params must not be {@literal null}. + * @return + * @see Redis Documentation: SORT + */ List sort(String key, SortParameters params); + /** + * Sort the elements for {@code key} and store result in {@code storeKey}. + * + * @param key must not be {@literal null}. + * @param params must not be {@literal null}. + * @param storeKey must not be {@literal null}. + * @return + * @see Redis Documentation: SORT + */ Long sort(String key, SortParameters params, String storeKey); + // ------------------------------------------------------------------------- + // Methods dealing with values/Redis strings + // ------------------------------------------------------------------------- + /** * Get the value of {@code key}. - *

- * See http://redis.io/commands/get * * @param key must not be {@literal null}. * @return + * @see Redis Documentation: GET + * @see RedisStringCommands#get(byte[]) */ String get(String key); /** - * Set value of {@code key} and return its old value. - *

- * 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 Redis Documentation: GETSET + * @see RedisStringCommands#getSet(byte[], byte[]) */ String getSet(String key, String value); /** - * Get the values of all given {@code keys}. - *

- * See http://redis.io/commands/mget + * Get multiple {@code keys}. Values are returned in the order of the requested keys. * - * @param keys + * @param keys must not be {@literal null}. * @return + * @see Redis Documentation: MGET + * @see RedisStringCommands#mGet(byte[]...) */ List mGet(String... keys); /** * Set {@code value} for {@code key}. - *

- * See http://redis.io/commands/set * * @param key must not be {@literal null}. * @param value must not be {@literal null}. + * @see Redis Documentation: SET + * @see RedisStringCommands#set(byte[], byte[]) */ void set(String key, String value); /** * Set {@code value} for {@code key} applying timeouts from {@code expiration} if set and inserting/updating values * depending on {@code option}. - *

- * 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 Redis Documentation: SET + * @see RedisStringCommands#set(byte[], byte[], Expiration, SetOption) */ void set(String key, String value, Expiration expiration, SetOption option); /** * Set {@code value} for {@code key}, only if {@code key} does not exist. - *

- * See http://redis.io/commands/setnx * * @param key must not be {@literal null}. * @param value must not be {@literal null}. * @return + * @see Redis Documentation: SETNX + * @see RedisStringCommands#setNX(byte[], byte[]) */ Boolean setNX(String key, String value); /** * Set the {@code value} and expiration in {@code seconds} for {@code key}. - *

- * See http://redis.io/commands/setex * * @param key must not be {@literal null}. * @param seconds * @param value must not be {@literal null}. + * @see Redis Documentation: SETEX + * @see RedisStringCommands#setEx(byte[], long, byte[]) */ void setEx(String key, long seconds, String value); /** * Set the {@code value} and expiration in {@code milliseconds} for {@code key}. - *

- * 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 Redis Documentation: PSETEX + * @see RedisStringCommands#pSetEx(byte[], long, byte[]) */ void pSetEx(String key, long milliseconds, String value); /** * Set multiple keys to multiple values using key-value pairs provided in {@code tuple}. - *

- * See http://redis.io/commands/mset * - * @param tuple + * @param tuple must not be {@literal null}. + * @see Redis Documentation: MSET + * @see RedisStringCommands#mSet(Map) */ void mSetString(Map tuple); /** * Set multiple keys to multiple values using key-value pairs provided in {@code tuple} only if the provided key does * not exist. - *

- * See http://redis.io/commands/msetnx * - * @param tuple + * @param tuple must not be {@literal null}. + * @see Redis Documentation: MSETNX + * @see RedisStringCommands#mSetNX(Map) */ Boolean mSetNXString(Map tuple); /** - * Increment value of {@code key} by 1. - *

- * 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 Redis Documentation: INCR + * @see RedisStringCommands#incr(byte[]) */ Long incr(String key); /** - * Increment value of {@code key} by {@code value}. - *

- * 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 Redis Documentation: INCRBY + * @see RedisStringCommands#incrBy(byte[], long) */ Long incrBy(String key, long value); /** - * Increment value of {@code key} by {@code value}. - *

- * 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 Redis Documentation: INCRBYFLOAT + * @see RedisStringCommands#incrBy(byte[], double) */ Double incrBy(String key, double value); /** - * Decrement value of {@code key} by 1. - *

- * 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 Redis Documentation: DECR + * @see RedisStringCommands#decr(byte[]) */ Long decr(String key); /** - * Increment value of {@code key} by {@code value}. - *

- * 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 Redis Documentation: DECRBY + * @see RedisStringCommands#decrBy(byte[], long) */ Long decrBy(String key, long value); /** * Append a {@code value} to {@code key}. - *

- * See http://redis.io/commands/append * * @param key must not be {@literal null}. * @param value * @return + * @see Redis Documentation: APPEND + * @see RedisStringCommands#append(byte[], byte[]) */ Long append(String key, String value); /** - * Get a substring of value of {@code key} between {@code begin} and {@code end}. - *

- * See http://redis.io/commands/getrange + * Get a substring of value of {@code key} between {@code start} and {@code end}. * * @param key must not be {@literal null}. * @param start * @param end * @return + * @see Redis Documentation: GETRANGE + * @see RedisStringCommands#getRange(byte[], long, long) */ String getRange(String key, long start, long end); /** * Overwrite parts of {@code key} starting at the specified {@code offset} with given {@code value}. - *

- * See http://redis.io/commands/setrange * * @param key must not be {@literal null}. * @param value * @param offset + * @see Redis Documentation: SETRANGE + * @see RedisStringCommands#setRange(byte[], byte[], long) */ void setRange(String key, String value, long offset); /** * Get the bit value at {@code offset} of value at {@code key}. - *

- * See http://redis.io/commands/getbit * * @param key must not be {@literal null}. * @param offset * @return + * @see Redis Documentation: GETBIT + * @see RedisStringCommands#getBit(byte[], long) */ Boolean getBit(String key, long offset); /** * Sets the bit at {@code offset} in value stored at {@code key}. - *

- * See http://redis.io/commands/setbit * * @param key must not be {@literal null}. * @param offset * @param value * @return the original bit value stored at {@code offset}. + * @see Redis Documentation: SETBIT + * @see RedisStringCommands#setBit(byte[], long, boolean) */ Boolean setBit(String key, long offset, boolean value); /** * Count the number of set bits (population counting) in value stored at {@code key}. - *

- * See http://redis.io/commands/bitcount * * @param key must not be {@literal null}. * @return + * @see Redis Documentation: BITCOUNT + * @see RedisStringCommands#bitCount(byte[]) */ Long bitCount(String key); /** - * Count the number of set bits (population counting) of value stored at {@code key} between {@code begin} and + * Count the number of set bits (population counting) of value stored at {@code key} between {@code start} and * {@code end}. - *

- * See http://redis.io/commands/bitcount * * @param key must not be {@literal null}. - * @param begin + * @param start * @param end * @return + * @see Redis Documentation: BITCOUNT + * @see RedisStringCommands#bitCount(byte[], long, long) */ - Long bitCount(String key, long begin, long end); + Long bitCount(String key, long start, long end); /** * Perform bitwise operations between strings. - *

- * 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 Redis Documentation: BITOP + * @see RedisStringCommands#bitOp(BitOperation, byte[], byte[]...) */ Long bitOp(BitOperation op, String destination, String... keys); /** * Get the length of the value stored at {@code key}. - *

- * See http://redis.io/commands/strlen * * @param key must not be {@literal null}. * @return + * @see Redis Documentation: STRLEN + * @see RedisStringCommands#strLen(byte[]) */ Long strLen(String key); + // ------------------------------------------------------------------------- + // Methods dealing with Redis Lists + // ------------------------------------------------------------------------- + + /** + * Append {@code values} to {@code key}. + * + * @param key must not be {@literal null}. + * @param values + * @return + * @see Redis Documentation: RPUSH + * @see RedisListCommands#rPush(byte[], byte[]...) + */ Long rPush(String key, String... values); + /** + * Prepend {@code values} to {@code key}. + * + * @param key must not be {@literal null}. + * @param values + * @return + * @see Redis Documentation: LPUSH + * @see RedisListCommands#lPush(byte[], byte[]...) + */ Long lPush(String key, String... values); + /** + * Append {@code values} to {@code key} only if the list exists. + * + * @param key must not be {@literal null}. + * @param value + * @return + * @see Redis Documentation: RPUSHX + * @see RedisListCommands#rPushX(byte[], byte[]) + */ Long rPushX(String key, String value); + /** + * Prepend {@code values} to {@code key} only if the list exists. + * + * @param key must not be {@literal null}. + * @param value + * @return + * @see Redis Documentation: LPUSHX + * @see RedisListCommands#lPushX(byte[], byte[]) + */ Long lPushX(String key, String value); + /** + * Get the size of list stored at {@code key}. + * + * @param key must not be {@literal null}. + * @return + * @see Redis Documentation: LLEN + * @see RedisListCommands#lLen(byte[]) + */ Long lLen(String key); + /** + * 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 Redis Documentation: LRANGE + * @see RedisListCommands#lRange(byte[], long, long) + */ List lRange(String 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 Redis Documentation: LTRIM + * @see RedisListCommands#lTrim(byte[], long, long) + */ void lTrim(String key, long start, long end); + /** + * Get element at {@code index} form list at {@code key}. + * + * @param key must not be {@literal null}. + * @param index + * @return + * @see Redis Documentation: LINDEX + * @see RedisListCommands#lIndex(byte[], long) + */ String lIndex(String key, long index); + /** + * Insert {@code value} {@link Position#BEFORE} or {@link Position#AFTER} existing {@code pivot} for {@code key}. + * + * @param key must not be {@literal null}. + * @param where must not be {@literal null}. + * @param pivot + * @param value + * @return + * @see Redis Documentation: LINSERT + * @see RedisListCommands#lIndex(byte[], long) + */ Long lInsert(String key, Position where, String pivot, String value); + /** + * Set the {@code value} list element at {@code index}. + * + * @param key must not be {@literal null}. + * @param index + * @param value + * @see Redis Documentation: LSET + * @see RedisListCommands#lSet(byte[], long, byte[]) + */ void lSet(String key, long index, String 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 Redis Documentation: LREM + * @see RedisListCommands#lRem(byte[], long, byte[]) + */ Long lRem(String key, long count, String value); + /** + * Removes and returns first element in list stored at {@code key}. + * + * @param key must not be {@literal null}. + * @return + * @see Redis Documentation: LPOP + * @see RedisListCommands#lPop(byte[]) + */ String lPop(String key); + /** + * Removes and returns last element in list stored at {@code key}. + * + * @param key must not be {@literal null}. + * @return + * @see Redis Documentation: RPOP + * @see RedisListCommands#rPop(byte[]) + */ String rPop(String key); + /** + * Removes and returns first element from lists stored at {@code keys} (see: {@link #lPop(byte[])}).
+ * Blocks connection until element available or {@code timeout} reached. + * + * @param timeout + * @param keys must not be {@literal null}. + * @return + * @see Redis Documentation: BLPOP + * @see RedisListCommands#bLPop(int, byte[]...) + */ List bLPop(int timeout, String... keys); + /** + * Removes and returns last element from lists stored at {@code keys} (see: {@link #rPop(byte[])}).
+ * Blocks connection until element available or {@code timeout} reached. + * + * @param timeout + * @param keys must not be {@literal null}. + * @return + * @see Redis Documentation: BRPOP + * @see RedisListCommands#bRPop(int, byte[]...) + */ List bRPop(int timeout, String... keys); + /** + * Remove the last element from list at {@code srcKey}, append it to {@code dstKey} and return its value. + * + * @param srcKey must not be {@literal null}. + * @param dstKey must not be {@literal null}. + * @return + * @see Redis Documentation: RPOPLPUSH + * @see RedisListCommands#rPopLPush(byte[], byte[]) + */ String rPopLPush(String srcKey, String dstKey); + /** + * Remove the last element from list at {@code srcKey}, append it to {@code dstKey} and return its value (see + * {@link #rPopLPush(byte[], byte[])}).
+ * Blocks connection until element available or {@code timeout} reached. + * + * @param timeout + * @param srcKey must not be {@literal null}. + * @param dstKey must not be {@literal null}. + * @return + * @see Redis Documentation: BRPOPLPUSH + * @see RedisListCommands#bRPopLPush(int, byte[], byte[]) + */ String bRPopLPush(int timeout, String srcKey, String dstKey); + // ------------------------------------------------------------------------- + // Methods dealing with Redis Sets + // ------------------------------------------------------------------------- + + /** + * Add given {@code values} to set at {@code key}. + * + * @param key must not be {@literal null}. + * @param values + * @return + * @see Redis Documentation: SADD + * @see RedisSetCommands#sAdd(byte[], byte[]...) + */ Long sAdd(String key, String... values); + /** + * 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 Redis Documentation: SREM + * @see RedisSetCommands#sRem(byte[], byte[]...) + */ Long sRem(String key, String... values); + /** + * Remove and return a random member from set at {@code key}. + * + * @param key must not be {@literal null}. + * @return + * @see Redis Documentation: SPOP + * @see RedisSetCommands#sPop(byte[]) + */ String sPop(String key); + /** + * Move {@code value} from {@code srcKey} to {@code destKey} + * + * @param srcKey must not be {@literal null}. + * @param destKey must not be {@literal null}. + * @param value + * @return + * @see Redis Documentation: SMOVE + * @see RedisSetCommands#sMove(byte[], byte[], byte[]) + */ Boolean sMove(String srcKey, String destKey, String value); + /** + * Get size of set at {@code key}. + * + * @param key must not be {@literal null}. + * @return + * @see Redis Documentation: SCARD + * @see RedisSetCommands#sCard(byte[]) + */ Long sCard(String key); + /** + * Check if set at {@code key} contains {@code value}. + * + * @param key must not be {@literal null}. + * @param value + * @return + * @see Redis Documentation: SISMEMBER + * @see RedisSetCommands#sIsMember(byte[], byte[]) + */ Boolean sIsMember(String key, String value); + /** + * Returns the members intersecting all given sets at {@code keys}. + * + * @param keys must not be {@literal null}. + * @return + * @see Redis Documentation: SINTER + * @see RedisSetCommands#sInter(byte[]...) + */ Set sInter(String... keys); + /** + * Intersect all given sets at {@code keys} and store result in {@code destKey}. + * + * @param destKey must not be {@literal null}. + * @param keys must not be {@literal null}. + * @return + * @see Redis Documentation: SINTERSTORE + * @see RedisSetCommands#sInterStore(byte[], byte[]...) + */ Long sInterStore(String destKey, String... keys); + /** + * Union all sets at given {@code keys}. + * + * @param keys must not be {@literal null}. + * @return + * @see Redis Documentation: SUNION + * @see RedisSetCommands#sUnion(byte[]...) + */ Set sUnion(String... keys); + /** + * Union all sets at 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 Redis Documentation: SUNIONSTORE + * @see RedisSetCommands#sUnionStore(byte[], byte[]...) + */ Long sUnionStore(String destKey, String... keys); + /** + * Diff all sets for given {@code keys}. + * + * @param keys must not be {@literal null}. + * @return + * @see Redis Documentation: SDIFF + * @see RedisSetCommands#sDiff(byte[]...) + */ Set sDiff(String... 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 Redis Documentation: SDIFFSTORE + * @see RedisSetCommands#sDiffStore(byte[], byte[]...) + */ Long sDiffStore(String destKey, String... keys); + /** + * Get all elements of set at {@code key}. + * + * @param key must not be {@literal null}. + * @return + * @see Redis Documentation: SMEMBERS + * @see RedisSetCommands#sMembers(byte[]) + */ Set sMembers(String key); + /** + * Get random element from set at {@code key}. + * + * @param key must not be {@literal null}. + * @return + * @see Redis Documentation: SRANDMEMBER + * @see RedisSetCommands#sRandMember(byte[]) + */ String sRandMember(String key); + /** + * Get {@code count} random elements from set at {@code key}. + * + * @param key must not be {@literal null}. + * @param count + * @return + * @see Redis Documentation: SRANDMEMBER + * @see RedisSetCommands#sRem(byte[], byte[]...) + */ List sRandMember(String key, long count); - Boolean zAdd(String key, double score, String value); - - Long zAdd(String key, Set tuples); - - Long zRem(String key, String... values); - - Double zIncrBy(String key, double increment, String value); - - Long zRank(String key, String value); - - Long zRevRank(String key, String value); - - Set zRange(String key, long start, long end); - - Set zRangeWithScores(String key, long start, long end); - - Set zRevRange(String key, long start, long end); - - Set zRevRangeWithScores(String key, long start, long end); - - Set zRevRangeByScore(String key, double min, double max); - - Set zRevRangeByScoreWithScores(String key, double min, double max); - - Set zRevRangeByScore(String key, double min, double max, long offset, long count); - - Set zRevRangeByScoreWithScores(String key, double min, double max, long offset, long count); - - Set zRangeByScore(String key, double min, double max); - - Set zRangeByScoreWithScores(String key, double min, double max); - - Set zRangeByScore(String key, double min, double max, long offset, long count); - - Set zRangeByScoreWithScores(String key, double min, double max, long offset, long count); - - Long zCount(String key, double min, double max); - - Long zCard(String key); - - Double zScore(String key, String value); - - Long zRemRange(String key, long start, long end); - - Long zRemRangeByScore(String key, double min, double max); - - Long zUnionStore(String destKey, String... sets); - - Long zUnionStore(String destKey, Aggregate aggregate, int[] weights, String... sets); - - Long zInterStore(String destKey, String... sets); - - Long zInterStore(String destKey, Aggregate aggregate, int[] weights, String... sets); - - Boolean hSet(String key, String field, String value); - - Boolean hSetNX(String key, String field, String value); - - String hGet(String key, String field); - - List hMGet(String key, String... fields); - - void hMSet(String key, Map hashes); - - Long hIncrBy(String key, String field, long delta); - - Double hIncrBy(String key, String field, double delta); - - Boolean hExists(String key, String field); - - Long hDel(String key, String... fields); - - Long hLen(String key); - - Set hKeys(String key); - - List hVals(String key); - - Map hGetAll(String key); - - Long publish(String channel, String message); - - void subscribe(MessageListener listener, String... channels); - - void pSubscribe(MessageListener listener, String... patterns); - - String scriptLoad(String script); - - T eval(String script, ReturnType returnType, int numKeys, String... keysAndArgs); - - T evalSha(String scriptSha1, ReturnType returnType, int numKeys, String... keysAndArgs); - /** - * Assign given {@code name} to connection using registered {@link RedisSerializer} for name conversion. - * - * @param name - * @see #setClientName(byte[]) - * @since 1.3 - */ - void setClientName(String name); - - /** - * @see RedisConnection#getClientList() - * @since 1.3 - */ - List getClientList(); - - /** - * @since 1.4 - * @see RedisHashCommands#hScan(byte[], ScanOptions) + * Use a {@link Cursor} to iterate over elements in set at {@code key}. + * * @param key must not be {@literal null}. - * @param options + * @param options must not be {@literal null}. * @return - */ - Cursor> hScan(String key, ScanOptions options); - - /** * @since 1.4 + * @see Redis Documentation: SCAN * @see RedisSetCommands#sScan(byte[], ScanOptions) - * @param key must not be {@literal null}. - * @param options - * @return */ Cursor sScan(String key, ScanOptions options); - /** - * @since 1.4 - * @see RedisZSetCommands#zScan(byte[], ScanOptions) - * @param key must not be {@literal null}. - * @param options - * @return - */ - Cursor zScan(String key, ScanOptions options); + // ------------------------------------------------------------------------- + // Methods dealing with Redis Sorted Sets + // ------------------------------------------------------------------------- /** - * @since 1.5 + * 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 Redis Documentation: ZADD + * @see RedisZSetCommands#zAdd(byte[], double, byte[]) + */ + Boolean zAdd(String key, double score, String value); + + /** + * 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 the tuples. + * @return + * @see Redis Documentation: ZADD + * @see RedisZSetCommands#zAdd(byte[], Set) + */ + Long zAdd(String key, Set tuples); + + /** + * 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 Redis Documentation: ZREM + * @see RedisZSetCommands#zRem(byte[], byte[]...) + */ + Long zRem(String key, String... values); + + /** + * Increment the score of element with {@code value} in sorted set by {@code increment}. + * + * @param key must not be {@literal null}. + * @param increment + * @param value the value. + * @return + * @see Redis Documentation: ZINCRBY + * @see RedisZSetCommands#zIncrBy(byte[], double, byte[]) + */ + Double zIncrBy(String key, double increment, String value); + + /** + * Determine the index of element with {@code value} in a sorted set. + * + * @param key must not be {@literal null}. + * @param value the value. + * @return + * @see Redis Documentation: ZRANK + * @see RedisZSetCommands#zRank(byte[], byte[]) + */ + Long zRank(String key, String value); + + /** + * 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 value the value. + * @return + * @see Redis Documentation: ZREVRANK + * @see RedisZSetCommands#zRevRank(byte[], byte[]) + */ + Long zRevRank(String key, String value); + + /** + * Get elements between {@code start} and {@code end} from sorted set. + * + * @param key must not be {@literal null}. + * @param start + * @param end + * @return + * @see Redis Documentation: ZRANGE + * @see RedisZSetCommands#zRange(byte[], long, long) + */ + Set zRange(String 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 Redis Documentation: ZRANGE + * @see RedisZSetCommands#zRangeWithScores(byte[], long, long) + */ + Set zRangeWithScores(String 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 Redis Documentation: ZRANGEBYSCORE + * @see RedisZSetCommands#zRangeByScore(byte[], double, double) */ - Set zRangeByScore(String key, String min, String max); + Set zRangeByScore(String key, double min, double max); /** - * @since 1.5 + * 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 Redis Documentation: ZRANGEBYSCORE + * @see RedisZSetCommands#zRangeByScoreWithScores(byte[], double, double) + */ + Set zRangeByScoreWithScores(String 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 Redis Documentation: ZRANGEBYSCORE + * @see RedisZSetCommands#zRangeByScore(byte[], double, double, long, long) + */ + Set zRangeByScore(String 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 Redis Documentation: ZRANGEBYSCORE + * @see RedisZSetCommands#zRangeByScoreWithScores(byte[], double, double, long, long) + */ + Set zRangeByScoreWithScores(String 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 Redis Documentation: ZREVRANGE + * @see RedisZSetCommands#zRevRange(byte[], long, long) + */ + Set zRevRange(String 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 Redis Documentation: ZREVRANGE + * @see RedisZSetCommands#zRevRangeWithScores(byte[], long, long) + */ + Set zRevRangeWithScores(String 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 Redis Documentation: ZREVRANGE + * @see RedisZSetCommands#zRevRangeByScore(byte[], double, double) + */ + Set zRevRangeByScore(String 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 Redis Documentation: ZREVRANGEBYSCORE + * @see RedisZSetCommands#zRevRangeByScoreWithScores(byte[], double, double) + */ + Set zRevRangeByScoreWithScores(String 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 Redis Documentation: ZREVRANGEBYSCORE + * @see RedisZSetCommands#zRevRangeByScore(byte[], double, double, long, long) + */ + Set zRevRangeByScore(String 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 Redis Documentation: ZREVRANGEBYSCORE + * @see RedisZSetCommands#zRevRangeByScoreWithScores(byte[], double, double, long, long) + */ + Set zRevRangeByScoreWithScores(String 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 Redis Documentation: ZCOUNT + * @see RedisZSetCommands#zCount(byte[], double, double) + */ + Long zCount(String key, double min, double max); + + /** + * Get the size of sorted set with {@code key}. + * + * @param key must not be {@literal null}. + * @return + * @see Redis Documentation: ZCARD + * @see RedisZSetCommands#zCard(byte[]) + */ + Long zCard(String key); + + /** + * Get the score of element with {@code value} from sorted set with key {@code key}. + * + * @param key must not be {@literal null}. + * @param value the value. + * @return + * @see Redis Documentation: ZREM + * @see RedisZSetCommands#zScore(byte[], byte[]) + */ + Double zScore(String key, String value); + + /** + * 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 Redis Documentation: ZREMRANGEBYRANK + * @see RedisZSetCommands#zRemRange(byte[], long, long) + */ + Long zRemRange(String 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 Redis Documentation: ZREMRANGEBYSCORE + * @see RedisZSetCommands#zRemRangeByScore(byte[], double, double) + */ + Long zRemRangeByScore(String key, double min, double max); + + /** + * Union sorted {@code sets} and store result in destination {@code key}. + * + * @param destKey must not be {@literal null}. + * @param sets must not be {@literal null}. + * @return + * @see Redis Documentation: ZUNIONSTORE + * @see RedisZSetCommands#zUnionStore(byte[], byte[]...) + */ + Long zUnionStore(String destKey, String... sets); + + /** + * Union sorted {@code sets} and store result in destination {@code key}. + * + * @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 Redis Documentation: ZUNIONSTORE + * @see RedisZSetCommands#zUnionStore(byte[], Aggregate, int[], byte[]...) + */ + Long zUnionStore(String destKey, Aggregate aggregate, int[] weights, String... sets); + + /** + * Intersect sorted {@code sets} and store result in destination {@code key}. + * + * @param destKey must not be {@literal null}. + * @param sets must not be {@literal null}. + * @return + * @see Redis Documentation: ZINTERSTORE + * @see RedisZSetCommands#zInterStore(byte[], byte[]...) + */ + Long zInterStore(String destKey, String... sets); + + /** + * Intersect sorted {@code sets} and store result in destination {@code key}. + * + * @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 Redis Documentation: ZINTERSTORE + * @see RedisZSetCommands#zInterStore(byte[], Aggregate, int[], byte[]...) + */ + Long zInterStore(String destKey, Aggregate aggregate, int[] weights, String... sets); + + /** + * Use a {@link Cursor} to iterate over elements in sorted set at {@code key}. + * + * @param key must not be {@literal null}. + * @param options must not be {@literal null}. + * @return + * @since 1.4 + * @see Redis Documentation: ZSCAN + * @see RedisZSetCommands#zScan(byte[], ScanOptions) + */ + Cursor zScan(String key, ScanOptions options); + + /** + * Get elements where score is between {@code min} and {@code max} from sorted set. + * + * @param key must not be {@literal null}. + * @param min must not be {@literal null}. + * @param max must not be {@literal null}. + * @return + * @since 1.5 + * @see Redis Documentation: ZRANGEBYSCORE + * @see RedisZSetCommands#zRangeByScore(byte[], String, String) + */ + Set zRangeByScore(String key, String min, String 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 must not be {@literal null}. + * @param max must not be {@literal null}. + * @param offset + * @param count + * @return + * @since 1.5 + * @see Redis Documentation: ZRANGEBYSCORE + * @see RedisZSetCommands#zRangeByScore(byte[], double, double, long, long) */ Set zRangeByScore(String key, String min, String max, long offset, long count); /** - * Adds given {@literal values} to the HyperLogLog stored at given {@literal key}. - * - * @param key must not be {@literal null}. - * @param values - * @return - * @since 1.5 - */ - Long pfAdd(String key, String... values); - - /** - * @param keys - * @return - * @since 1.5 - */ - Long pfCount(String... keys); - - /** - * @param destinationKey - * @param sourceKeys - * @since 1.5 - */ - void pfMerge(String destinationKey, String... sourceKeys); - - /** - * Get all elements in the sorted set at {@literal key} in lexicographical ordering. - * + * 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 Redis Documentation: ZRANGEBYLEX + * @see RedisZSetCommands#zRangeByLex(byte[]) */ Set zRangeByLex(String key); /** - * Get the elements in {@link Range} from the sorted set at {@literal key} in lexicographical ordering - * + * 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 Redis Documentation: ZRANGEBYLEX + * @see RedisZSetCommands#zRangeByLex(byte[], Range) */ Set zRangeByLex(String key, Range range); /** - * Get the elements in {@link Range} from the sorted set at {@literal key} in lexicographical ordering. Result is + * 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 Redis Documentation: ZRANGEBYLEX + * @see RedisZSetCommands#zRangeByLex(byte[], Range, Limit) */ Set zRangeByLex(String key, Range range, Limit limit); + // ------------------------------------------------------------------------- + // Methods dealing with Redis Hashes + // ------------------------------------------------------------------------- + + /** + * Set the {@code value} of a hash {@code field}. + * + * @param key must not be {@literal null}. + * @param field must not be {@literal null}. + * @param value + * @return + * @see Redis Documentation: HSET + * @see RedisHashCommands#hSet(byte[], byte[], byte[]) + */ + Boolean hSet(String key, String field, String value); + + /** + * Set the {@code value} of a hash {@code field} only if {@code field} does not exist. + * + * @param key must not be {@literal null}. + * @param field must not be {@literal null}. + * @param value + * @return + * @see Redis Documentation: HSETNX + * @see RedisHashCommands#hSetNX(byte[], byte[], byte[]) + */ + Boolean hSetNX(String key, String field, String value); + + /** + * Get value for given {@code field} from hash at {@code key}. + * + * @param key must not be {@literal null}. + * @param field must not be {@literal null}. + * @return + * @see Redis Documentation: HGET + * @see RedisHashCommands#hGet(byte[], byte[]) + */ + String hGet(String key, String field); + + /** + * Get values for given {@code fields} from hash at {@code key}. + * + * @param key must not be {@literal null}. + * @param fields must not be {@literal null}. + * @return + * @see Redis Documentation: HMGET + * @see RedisHashCommands#hMGet(byte[], byte[]...) + */ + List hMGet(String key, String... fields); + + /** + * Set multiple hash fields to multiple values using data provided in {@code hashes} + * + * @param key must not be {@literal null}. + * @param hashes must not be {@literal null}. + * @see Redis Documentation: HMSET + * @see RedisHashCommands#hMGet(byte[], byte[]...) + */ + void hMSet(String key, Map hashes); + + /** + * Increment {@code value} of a hash {@code field} by the given {@code delta}. + * + * @param key must not be {@literal null}. + * @param field must not be {@literal null}. + * @param delta + * @return + * @see Redis Documentation: HINCRBY + * @see RedisHashCommands#hIncrBy(byte[], byte[], long) + */ + Long hIncrBy(String key, String field, long delta); + + /** + * Increment {@code value} of a hash {@code field} by the given {@code delta}. + * + * @param key must not be {@literal null}. + * @param field + * @param delta + * @return + * @see Redis Documentation: HINCRBYFLOAT + * @see RedisHashCommands#hIncrBy(byte[], byte[], double) + */ + Double hIncrBy(String key, String field, double delta); + + /** + * Determine if given hash {@code field} exists. + * + * @param key must not be {@literal null}. + * @param field must not be {@literal null}. + * @return + * @see Redis Documentation: HEXISTS + * @see RedisHashCommands#hExists(byte[], byte[]) + */ + Boolean hExists(String key, String field); + + /** + * Delete given hash {@code fields}. + * + * @param key must not be {@literal null}. + * @param fields must not be {@literal null}. + * @return + * @see Redis Documentation: HDEL + * @see RedisHashCommands#hDel(byte[], byte[]...) + */ + Long hDel(String key, String... fields); + + /** + * Get size of hash at {@code key}. + * + * @param key must not be {@literal null}. + * @return + * @see Redis Documentation: HLEN + * @see RedisHashCommands#hLen(byte[]) + */ + Long hLen(String key); + + /** + * Get key set (fields) of hash at {@code key}. + * + * @param key must not be {@literal null}. + * @return + * @see Redis Documentation: HKEYS? + * @see RedisHashCommands#hKeys(byte[]) + */ + Set hKeys(String key); + + /** + * Get entry set (values) of hash at {@code field}. + * + * @param key must not be {@literal null}. + * @return + * @see Redis Documentation: HVALS + * @see RedisHashCommands#hVals(byte[]) + */ + List hVals(String key); + + /** + * Get entire hash stored at {@code key}. + * + * @param key must not be {@literal null}. + * @return + * @see Redis Documentation: HGETALL + * @see RedisHashCommands#hGetAll(byte[]) + */ + Map hGetAll(String key); + + /** + * Use a {@link Cursor} to iterate over entries in hash at {@code key}. + * + * @param key must not be {@literal null}. + * @param options must not be {@literal null}. + * @return + * @since 1.4 + * @see Redis Documentation: HSCAN + * @see RedisHashCommands#hScan(byte[], ScanOptions) + */ + Cursor> hScan(String key, ScanOptions options); + + // ------------------------------------------------------------------------- + // Methods dealing with HyperLogLog + // ------------------------------------------------------------------------- + + /** + * Adds given {@literal values} to the HyperLogLog stored at given {@literal key}. + * + * @param key must not be {@literal null}. + * @param values must not be {@literal null}. + * @return + * @since 1.5 + * @see Redis Documentation: PFADD + * @see HyperLogLogCommands#pfAdd(byte[], byte[]...) + */ + Long pfAdd(String key, String... values); + + /** + * Return the approximated cardinality of the structures observed by the HyperLogLog at {@literal key(s)}. + * + * @param keys must not be {@literal null}. + * @return + * @see Redis Documentation: PFCOUNT + * @see HyperLogLogCommands#pfCount(byte[]...) + */ + Long pfCount(String... keys); + + /** + * Merge N different HyperLogLogs at {@literal sourceKeys} into a single {@literal destinationKey}. + * + * @param destinationKey must not be {@literal null}. + * @param sourceKeys must not be {@literal null}. + * @see Redis Documentation: PFMERGE + * @see HyperLogLogCommands#pfMerge(byte[], byte[]...) + */ + void pfMerge(String destinationKey, String... sourceKeys); + + // ------------------------------------------------------------------------- + // Methods dealing with Redis Geo-Indexes + // ------------------------------------------------------------------------- + /** * Add {@link Point} with given member {@literal name} to {@literal key}. - * + * * @param key must not be {@literal null}. * @param point must not be {@literal null}. * @param member must not be {@literal null}. * @return Number of elements added. - * @see http://redis.io/commands/geoadd * @since 1.8 + * @see Redis Documentation: GEOADD + * @see RedisGeoCommands#geoAdd(byte[], Point, byte[]) */ Long geoAdd(String key, Point point, String member); /** * Add {@link GeoLocation} to {@literal key}. - * + * * @param key must not be {@literal null}. * @param location must not be {@literal null}. * @return Number of elements added. - * @see http://redis.io/commands/geoadd * @since 1.8 + * @see Redis Documentation: GEOADD + * @see RedisGeoCommands#geoAdd(byte[], GeoLocation) */ Long geoAdd(String key, GeoLocation location); /** * Add {@link Map} of member / {@link Point} pairs to {@literal key}. - * + * * @param key must not be {@literal null}. * @param memberCoordinateMap must not be {@literal null}. * @return Number of elements added. - * @see http://redis.io/commands/geoadd * @since 1.8 + * @see Redis Documentation: GEOADD + * @see RedisGeoCommands#geoAdd(byte[], Map) */ Long geoAdd(String key, Map memberCoordinateMap); /** * Add {@link GeoLocation}s to {@literal key} - * + * * @param key must not be {@literal null}. * @param locations must not be {@literal null}. * @return Number of elements added. - * @see http://redis.io/commands/geoadd * @since 1.8 + * @see Redis Documentation: GEOADD + * @see RedisGeoCommands#geoAdd(byte[], Iterable) */ Long geoAdd(String key, Iterable> locations); @@ -826,8 +1586,9 @@ public interface StringRedisConnection extends RedisConnection { * @param member1 must not be {@literal null}. * @param member2 must not be {@literal null}. * @return can be {@literal null}. - * @see http://redis.io/commands/geodist * @since 1.8 + * @see Redis Documentation: GEODIST + * @see RedisGeoCommands#geoDist(byte[], byte[], byte[]) */ Distance geoDist(String key, String member1, String member2); @@ -839,8 +1600,9 @@ public interface StringRedisConnection extends RedisConnection { * @param member2 must not be {@literal null}. * @param metric must not be {@literal null}. * @return can be {@literal null}. - * @see http://redis.io/commands/geodist * @since 1.8 + * @see Redis Documentation: GEODIST + * @see RedisGeoCommands#geoDist(byte[], byte[], byte[], Metric) */ Distance geoDist(String key, String member1, String member2, Metric metric); @@ -850,8 +1612,9 @@ public interface StringRedisConnection extends RedisConnection { * @param key must not be {@literal null}. * @param members must not be {@literal null}. * @return never {@literal null}. - * @see http://redis.io/commands/geohash * @since 1.8 + * @see Redis Documentation: GEOHASH + * @see RedisGeoCommands#geoHash(byte[], byte[]...) */ List geoHash(String key, String... members); @@ -861,8 +1624,9 @@ public interface StringRedisConnection extends RedisConnection { * @param key must not be {@literal null}. * @param members must not be {@literal null}. * @return never {@literal null}. - * @see http://redis.io/commands/geopos * @since 1.8 + * @see Redis Documentation: GEOPOS + * @see RedisGeoCommands#geoPos(byte[], byte[]...) */ List geoPos(String key, String... members); @@ -872,8 +1636,9 @@ public interface StringRedisConnection extends RedisConnection { * @param key must not be {@literal null}. * @param within must not be {@literal null}. * @return never {@literal null}. - * @see http://redis.io/commands/georadius * @since 1.8 + * @see Redis Documentation: GEORADIUS + * @see RedisGeoCommands#geoRadius(byte[], Circle) */ GeoResults> geoRadius(String key, Circle within); @@ -884,8 +1649,9 @@ public interface StringRedisConnection extends RedisConnection { * @param within must not be {@literal null}. * @param args must not be {@literal null}. * @return never {@literal null}. - * @see http://redis.io/commands/georadius * @since 1.8 + * @see Redis Documentation: GEORADIUS + * @see RedisGeoCommands#geoRadius(byte[], Circle, GeoRadiusCommandArgs) */ GeoResults> geoRadius(String key, Circle within, GeoRadiusCommandArgs args); @@ -897,8 +1663,9 @@ public interface StringRedisConnection extends RedisConnection { * @param member must not be {@literal null}. * @param radius * @return never {@literal null}. - * @see http://redis.io/commands/georadiusbymember * @since 1.8 + * @see Redis Documentation: GEORADIUSBYMEMBER + * @see RedisGeoCommands#geoRadiusByMember(byte[], byte[], double) */ GeoResults> geoRadiusByMember(String key, String member, double radius); @@ -910,8 +1677,9 @@ public interface StringRedisConnection extends RedisConnection { * @param member must not be {@literal null}. * @param radius must not be {@literal null}. * @return never {@literal null}. - * @see http://redis.io/commands/georadiusbymember * @since 1.8 + * @see Redis Documentation: GEORADIUSBYMEMBER + * @see RedisGeoCommands#geoRadiusByMember(byte[], byte[], Distance) */ GeoResults> geoRadiusByMember(String key, String member, Distance radius); @@ -924,8 +1692,9 @@ public interface StringRedisConnection extends RedisConnection { * @param radius must not be {@literal null}. * @param args must not be {@literal null}. * @return never {@literal null}. - * @see http://redis.io/commands/georadiusbymember * @since 1.8 + * @see Redis Documentation: GEORADIUSBYMEMBER + * @see RedisGeoCommands#geoRadiusByMember(byte[], byte[], Distance, GeoRadiusCommandArgs) */ GeoResults> geoRadiusByMember(String key, String member, Distance radius, GeoRadiusCommandArgs args); @@ -935,8 +1704,114 @@ public interface StringRedisConnection extends RedisConnection { * * @param key must not be {@literal null}. * @param members must not be {@literal null}. - * @return Number of members elements removed. * @since 1.8 + * @return Number of members elements removed. + * @see Redis Documentation: ZREM + * @see RedisGeoCommands#geoRemove(byte[], byte[]...) */ Long geoRemove(String key, String... members); + + // ------------------------------------------------------------------------- + // Methods dealing with Redis Pub/Sub + // ------------------------------------------------------------------------- + + /** + * Publishes the given message to the given channel. + * + * @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 Redis Documentation: PUBLISH + * @see RedisPubSubCommands#publish(byte[], byte[]) + */ + Long publish(String channel, String message); + + /** + * Subscribes the connection to the given channels. Once subscribed, a connection enters listening mode and can only + * subscribe to other channels or unsubscribe. No other commands are accepted until the connection is unsubscribed. + *

+ * Note that this operation is blocking and the current thread starts waiting for new messages immediately. + * + * @param listener message listener, must not be {@literal null}. + * @param channels channel names, must not be {@literal null}. + * @see Redis Documentation: SUBSCRIBE + * @see RedisPubSubCommands#subscribe(MessageListener, byte[]...) + */ + void subscribe(MessageListener listener, String... channels); + + /** + * Subscribes the connection to all channels matching the given patterns. Once subscribed, a connection enters + * listening mode and can only subscribe to other channels or unsubscribe. No other commands are accepted until the + * connection is unsubscribed. + *

+ * Note that this operation is blocking and the current thread starts waiting for new messages immediately. + * + * @param listener message listener, must not be {@literal null}. + * @param patterns channel name patterns, must not be {@literal null}. + * @see Redis Documentation: PSUBSCRIBE + * @see RedisPubSubCommands#pSubscribe(MessageListener, byte[]...) + */ + void pSubscribe(MessageListener listener, String... patterns); + + // ------------------------------------------------------------------------- + // Methods dealing with Redis Lua Scripting + // ------------------------------------------------------------------------- + + /** + * Load lua script into scripts cache, without executing it.
+ * Execute the script by calling {@link #evalSha(byte[], ReturnType, int, byte[]...)}. + * + * @param script must not be {@literal null}. + * @return + * @see Redis Documentation: SCRIPT LOAD + * @see RedisScriptingCommands#scriptLoad(byte[]) + */ + String scriptLoad(String script); + + /** + * Evaluate given {@code script}. + * + * @param script must not be {@literal null}. + * @param returnType must not be {@literal null}. + * @param numKeys + * @param keysAndArgs must not be {@literal null}. + * @return + * @see Redis Documentation: EVAL + * @see RedisScriptingCommands#eval(byte[], ReturnType, int, byte[]...) + */ + T eval(String script, ReturnType returnType, int numKeys, String... keysAndArgs); + + /** + * Evaluate given {@code scriptSha}. + * + * @param scriptSha must not be {@literal null}. + * @param returnType must not be {@literal null}. + * @param numKeys + * @param keysAndArgs must not be {@literal null}. + * @return + * @see Redis Documentation: EVALSHA + * @see RedisScriptingCommands#evalSha(String, ReturnType, int, byte[]...) + */ + T evalSha(String scriptSha, ReturnType returnType, int numKeys, String... keysAndArgs); + + /** + * Assign given name to current connection. + * + * @param name + * @since 1.3 + * @see Redis Documentation: CLIENT SETNAME + * @see RedisServerCommands#setClientName(byte[]) + */ + void setClientName(String name); + + /** + * Request information and statistics about connected clients. + * + * @return {@link List} of {@link RedisClientInfo} objects. + * @since 1.3 + * @see Redis Documentation: CLIENT LIST + * @see RedisServerCommands#getClientList() + */ + List getClientList(); + } diff --git a/src/main/java/org/springframework/data/redis/core/BoundGeoOperations.java b/src/main/java/org/springframework/data/redis/core/BoundGeoOperations.java index ed4f0162d..52538218b 100644 --- a/src/main/java/org/springframework/data/redis/core/BoundGeoOperations.java +++ b/src/main/java/org/springframework/data/redis/core/BoundGeoOperations.java @@ -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 extends BoundKeyOperations { * @param point must not be {@literal null}. * @param member must not be {@literal null}. * @return Number of elements added. - * @see http://redis.io/commands/geoadd + * @see Redis Documentation: GEOADD */ Long geoAdd(Point point, M member); @@ -50,7 +50,7 @@ public interface BoundGeoOperations extends BoundKeyOperations { * * @param location must not be {@literal null}. * @return Number of elements added. - * @see http://redis.io/commands/geoadd + * @see Redis Documentation: GEOADD */ Long geoAdd(GeoLocation location); @@ -59,7 +59,7 @@ public interface BoundGeoOperations extends BoundKeyOperations { * * @param memberCoordinateMap must not be {@literal null}. * @return Number of elements added. - * @see http://redis.io/commands/geoadd + * @see Redis Documentation: GEOADD */ Long geoAdd(Map memberCoordinateMap); @@ -68,7 +68,7 @@ public interface BoundGeoOperations extends BoundKeyOperations { * * @param locations must not be {@literal null}. * @return Number of elements added. - * @see http://redis.io/commands/geoadd + * @see Redis Documentation: GEOADD */ Long geoAdd(Iterable> locations); @@ -78,7 +78,7 @@ public interface BoundGeoOperations extends BoundKeyOperations { * @param member1 must not be {@literal null}. * @param member2 must not be {@literal null}. * @return can be {@literal null}. - * @see http://redis.io/commands/geodist + * @see Redis Documentation: GEODIST */ Distance geoDist(M member1, M member2); @@ -89,7 +89,7 @@ public interface BoundGeoOperations extends BoundKeyOperations { * @param member2 must not be {@literal null}. * @param metric must not be {@literal null}. * @return can be {@literal null}. - * @see http://redis.io/commands/geodist + * @see Redis Documentation: GEODIST */ Distance geoDist(M member1, M member2, Metric metric); @@ -98,7 +98,7 @@ public interface BoundGeoOperations extends BoundKeyOperations { * * @param members must not be {@literal null}. * @return never {@literal null}. - * @see http://redis.io/commands/geohash + * @see Redis Documentation: GEOHASH */ List geoHash(M... members); @@ -107,7 +107,7 @@ public interface BoundGeoOperations extends BoundKeyOperations { * * @param members must not be {@literal null}. * @return never {@literal null}. - * @see http://redis.io/commands/geopos + * @see Redis Documentation: GEOPOS */ List geoPos(M... members); @@ -116,7 +116,7 @@ public interface BoundGeoOperations extends BoundKeyOperations { * * @param within must not be {@literal null}. * @return never {@literal null}. - * @see http://redis.io/commands/georadius + * @see Redis Documentation: GEORADIUS */ GeoResults> geoRadius(Circle within); @@ -126,7 +126,7 @@ public interface BoundGeoOperations extends BoundKeyOperations { * @param within must not be {@literal null}. * @param args must not be {@literal null}. * @return never {@literal null}. - * @see http://redis.io/commands/georadius + * @see Redis Documentation: GEORADIUS */ GeoResults> geoRadius(Circle within, GeoRadiusCommandArgs args); @@ -137,7 +137,7 @@ public interface BoundGeoOperations extends BoundKeyOperations { * @param member must not be {@literal null}. * @param radius * @return never {@literal null}. - * @see http://redis.io/commands/georadiusbymember + * @see Redis Documentation: GEORADIUSBYMEMBER */ GeoResults> geoRadiusByMember(K key, M member, double radius); @@ -148,7 +148,7 @@ public interface BoundGeoOperations extends BoundKeyOperations { * @param member must not be {@literal null}. * @param distance must not be {@literal null}. * @return never {@literal null}. - * @see http://redis.io/commands/georadiusbymember + * @see Redis Documentation: GEORADIUSBYMEMBER */ GeoResults> geoRadiusByMember(M member, Distance distance); @@ -160,7 +160,7 @@ public interface BoundGeoOperations extends BoundKeyOperations { * @param distance must not be {@literal null}. * @param args must not be {@literal null}. * @return never {@literal null}. - * @see http://redis.io/commands/georadiusbymember + * @see Redis Documentation: GEORADIUSBYMEMBER */ GeoResults> geoRadiusByMember(M member, Distance distance, GeoRadiusCommandArgs args); diff --git a/src/main/java/org/springframework/data/redis/core/BoundHashOperations.java b/src/main/java/org/springframework/data/redis/core/BoundHashOperations.java index 81b5f1e65..8c39ce643 100644 --- a/src/main/java/org/springframework/data/redis/core/BoundHashOperations.java +++ b/src/main/java/org/springframework/data/redis/core/BoundHashOperations.java @@ -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 extends BoundKeyOperations { /** + * Delete given hash {@code keys} at the bound key. + * + * @param keys must not be {@literal null}. * @return */ - RedisOperations 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 extends BoundKeyOperations { 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 multiGet(Collection 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 extends BoundKeyOperations { 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 extends BoundKeyOperations { 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 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 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 extends BoundKeyOperations { Boolean putIfAbsent(HK key, HV value); /** - * Get values for given {@code keys} from the hash. - * - * @param keys must not be {@literal null}. - * @return - */ - List multiGet(Collection keys); - - /** - * Set multiple hash fields to multiple values using data provided in {@code m}. - * - * @param m must not be {@literal null}. - */ - void putAll(Map m); - - /** - * Get key set (fields) of the hash. - * - * @return - */ - Set keys(); - - /** - * Get entry set (values) of hash. + * Get entry set (values) of hash at the bound key. * * @return */ List 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 extends BoundKeyOperations { * @since 1.4 */ Cursor> scan(ScanOptions options); + + /** + * @return + */ + RedisOperations getOperations(); } diff --git a/src/main/java/org/springframework/data/redis/core/BoundKeyOperations.java b/src/main/java/org/springframework/data/redis/core/BoundKeyOperations.java index afe884984..088bd39d0 100644 --- a/src/main/java/org/springframework/data/redis/core/BoundKeyOperations.java +++ b/src/main/java/org/springframework/data/redis/core/BoundKeyOperations.java @@ -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. *

* As the rest of the APIs, if the underlying connection is pipelined or queued/in multi mode, all methods will return - * null. + * {@literal null}. *

* * @author Costin Leau * @author Christoph Strobl + * @author Mark Paluch */ public interface BoundKeyOperations { diff --git a/src/main/java/org/springframework/data/redis/core/BoundListOperations.java b/src/main/java/org/springframework/data/redis/core/BoundListOperations.java index afc890019..7347bd391 100644 --- a/src/main/java/org/springframework/data/redis/core/BoundListOperations.java +++ b/src/main/java/org/springframework/data/redis/core/BoundListOperations.java @@ -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 extends BoundKeyOperations { - RedisOperations getOperations(); - + /** + * Get elements between {@code begin} and {@code end} from list at the bound key. + * + * @param start + * @param end + * @return + * @see Redis Documentation: LRANGE + */ List range(long start, long end); + /** + * Trim list at the bound key to elements between {@code start} and {@code end}. + * + * @param start + * @param end + * @see Redis Documentation: LTRIM + */ void trim(long start, long end); + /** + * Get the size of list stored at the bound key. + * + * @return + * @see Redis Documentation: LLEN + */ Long size(); + /** + * Prepend {@code value} to the bound key. + * + * @param value + * @return + * @see Redis Documentation: LPUSH + */ Long leftPush(V value); + /** + * Prepend {@code values} to the bound key. + * + * @param values + * @return + * @see Redis Documentation: LPUSH + */ Long leftPushAll(V... values); + /** + * Prepend {@code values} to the bound key only if the list exists. + * + * @param value + * @return + * @see Redis Documentation: LPUSHX + */ Long leftPushIfPresent(V value); + /** + * Prepend {@code values} to the bound key before {@code value}. + * + * @param value + * @return + * @see Redis Documentation: LPUSH + */ Long leftPush(V pivot, V value); + /** + * Append {@code value} to the bound key. + * + * @param value + * @return + * @see Redis Documentation: RPUSH + */ Long rightPush(V value); + /** + * Append {@code values} to the bound key. + * + * @param values + * @return + * @see Redis Documentation: RPUSH + */ Long rightPushAll(V... values); + /** + * Append {@code values} to the bound key only if the list exists. + * + * @param value + * @return + * @see Redis Documentation: RPUSHX + */ Long rightPushIfPresent(V value); + /** + * Append {@code values} to the bound key before {@code value}. + * + * @param value + * @return + * @see Redis Documentation: RPUSH + */ Long rightPush(V pivot, V value); - V leftPop(); + /** + * Set the {@code value} list element at {@code index}. + * + * @param index + * @param value + * @see Redis Documentation: LSET + */ + 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 Redis Documentation: LREM + */ + Long remove(long count, Object value); + /** + * Get element at {@code index} form list at the bound key. + * + * @param index + * @return + * @see Redis Documentation: LINDEX + */ V index(long index); - void set(long index, V value); + /** + * Removes and returns first element in list stored at the bound key. + * + * @return + * @see Redis Documentation: LPOP + */ + V leftPop(); + + /** + * Removes and returns first element from lists stored at the bound key .
+ * Blocks connection until element available or {@code timeout} reached. + * + * @param timeout + * @param unit must not be {@literal null}. + * @return + * @see Redis Documentation: BLPOP + */ + V leftPop(long timeout, TimeUnit unit); + + /** + * Removes and returns last element in list stored at the bound key. + * + * @return + * @see Redis Documentation: RPOP + */ + V rightPop(); + + /** + * Removes and returns last element from lists stored at the bound key.
+ * Blocks connection until element available or {@code timeout} reached. + * + * @param timeout + * @param unit must not be {@literal null}. + * @return + * @see Redis Documentation: BRPOP + */ + V rightPop(long timeout, TimeUnit unit); + + RedisOperations getOperations(); } diff --git a/src/main/java/org/springframework/data/redis/core/BoundSetOperations.java b/src/main/java/org/springframework/data/redis/core/BoundSetOperations.java index 8d331e8da..6dd2526a3 100644 --- a/src/main/java/org/springframework/data/redis/core/BoundSetOperations.java +++ b/src/main/java/org/springframework/data/redis/core/BoundSetOperations.java @@ -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 extends BoundKeyOperations { - RedisOperations getOperations(); - - Set diff(K key); - - Set diff(Collection keys); - - void diffAndStore(K key, K destKey); - - void diffAndStore(Collection keys, K destKey); - - Set intersect(K key); - - Set intersect(Collection keys); - - void intersectAndStore(K key, K destKey); - - void intersectAndStore(Collection keys, K destKey); - - Set union(K key); - - Set union(Collection keys); - - void unionAndStore(K key, K destKey); - - void unionAndStore(Collection keys, K destKey); - + /** + * Add given {@code values} to set at the bound key. + * + * @param values + * @return + * @see Redis Documentation: SADD + */ Long add(V... values); - Boolean isMember(Object o); - - Set members(); - - Boolean move(K destKey, V value); - - V randomMember(); - - Set distinctRandomMembers(long count); - - List randomMembers(long count); - + /** + * Remove given {@code values} from set at the bound key and return the number of removed elements. + * + * @param values + * @return + * @see Redis Documentation: SREM + */ Long remove(Object... values); + /** + * Remove and return a random member from set at the bound key. + * + * @return + * @see Redis Documentation: SPOP + */ V pop(); + /** + * Move {@code value} from the bound key to {@code destKey} + * + * @param destKey must not be {@literal null}. + * @param value + * @return + * @see Redis Documentation: SMOVE + */ + Boolean move(K destKey, V value); + + /** + * Get size of set at the bound key. + * + * @return + * @see Redis Documentation: SCARD + */ Long size(); + /** + * Check if set at the bound key contains {@code value}. + * + * @param o + * @return + * @see Redis Documentation: SISMEMBER + */ + 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 Redis Documentation: SINTER + */ + Set 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 Redis Documentation: SINTER + */ + Set intersect(Collection 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 Redis Documentation: SINTERSTORE + */ + 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 Redis Documentation: SINTERSTORE + */ + void intersectAndStore(Collection keys, K destKey); + + /** + * Union all sets at given {@code key} and {@code key}. + * + * @param key must not be {@literal null}. + * @return + * @see Redis Documentation: SUNION + */ + Set union(K key); + + /** + * Union all sets at given {@code keys} and {@code keys}. + * + * @param keys must not be {@literal null}. + * @return + * @see Redis Documentation: SUNION + */ + Set union(Collection 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 Redis Documentation: SUNIONSTORE + */ + 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 Redis Documentation: SUNIONSTORE + */ + void unionAndStore(Collection keys, K destKey); + + /** + * Diff all sets for given the bound key and {@code key}. + * + * @param key must not be {@literal null}. + * @return + * @see Redis Documentation: SDIFF + */ + Set diff(K key); + + /** + * Diff all sets for given the bound key and {@code keys}. + * + * @param keys must not be {@literal null}. + * @return + * @see Redis Documentation: SDIFF + */ + Set diff(Collection 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 Redis Documentation: SDIFFSTORE + */ + 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 Redis Documentation: SDIFFSTORE + */ + void diffAndStore(Collection keys, K destKey); + + /** + * Get all elements of set at the bound key. + * + * @return + * @see Redis Documentation: SMEMBERS + */ + Set members(); + + /** + * Get random element from set at the bound key. + * + * @return + * @see Redis Documentation: SRANDMEMBER + */ + V randomMember(); + + /** + * Get {@code count} distinct random elements from set at the bound key. + * + * @param count + * @return + * @see Redis Documentation: SRANDMEMBER + */ + Set distinctRandomMembers(long count); + + /** + * Get {@code count} random elements from set at the bound key. + * + * @param count + * @return + * @see Redis Documentation: SRANDMEMBER + */ + List randomMembers(long count); + /** * @param options * @return * @since 1.4 */ Cursor scan(ScanOptions options); + + RedisOperations getOperations(); + } diff --git a/src/main/java/org/springframework/data/redis/core/BoundValueOperations.java b/src/main/java/org/springframework/data/redis/core/BoundValueOperations.java index 9d83159ca..8b3381d91 100644 --- a/src/main/java/org/springframework/data/redis/core/BoundValueOperations.java +++ b/src/main/java/org/springframework/data/redis/core/BoundValueOperations.java @@ -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 extends BoundKeyOperations { - RedisOperations getOperations(); - + /** + * Set {@code value} for the bound key. + * + * @param value + * @see Redis Documentation: SET + */ 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 Redis Documentation: SETEX + */ 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 Redis Documentation: SETNX + */ Boolean setIfAbsent(V value); + /** + * Get the value of the bound key. + * + * @see Redis Documentation: GET + */ V get(); - String get(long start, long end); - + /** + * Set {@code value} of the bound key and return its old value. + * + * @see Redis Documentation: GETSET + */ V getAndSet(V value); + /** + * Increment an integer value stored as string value under the bound key by {@code delta}. + * + * @param delta + * @see Redis Documentation: INCR + */ Long increment(long delta); + /** + * Increment a floating point number value stored as string value under the bound key by {@code delta}. + * + * @param delta + * @see Redis Documentation: INCRBYFLOAT + */ Double increment(double delta); + /** + * Append a {@code value} to the bound key. + * + * @param value + * @see Redis Documentation: APPEND + */ Integer append(String value); + /** + * Get a substring of value of the bound key between {@code begin} and {@code end}. + * + * @param start + * @param end + * @see Redis Documentation: GETRANGE + */ + 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 Redis Documentation: SETRANGE + */ + void set(V value, long offset); + + /** + * Get the length of the value stored at the bound key. + * + * @see Redis Documentation: STRLEN + */ Long size(); + + RedisOperations getOperations(); } diff --git a/src/main/java/org/springframework/data/redis/core/BoundZSetOperations.java b/src/main/java/org/springframework/data/redis/core/BoundZSetOperations.java index c34ef5dbc..2e5b0970c 100644 --- a/src/main/java/org/springframework/data/redis/core/BoundZSetOperations.java +++ b/src/main/java/org/springframework/data/redis/core/BoundZSetOperations.java @@ -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 extends BoundKeyOperations { - RedisOperations 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 Redis Documentation: ZADD + */ + 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 Redis Documentation: ZADD + */ + Long add(Set> tuples); - void intersectAndStore(Collection otherKeys, K destKey); + /** + * Remove {@code values} from sorted set. Return number of removed elements. + * + * @param values must not be {@literal null}. + * @return + * @see Redis Documentation: ZREM + */ + 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 Redis Documentation: ZINCRBY + */ + Double incrementScore(V value, double delta); + + /** + * Determine the index of element with {@code value} in a sorted set. + * + * @param o the value. + * @return + * @see Redis Documentation: ZRANK + */ + 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 Redis Documentation: ZREVRANK + */ + Long reverseRank(Object o); + + /** + * Get elements between {@code start} and {@code end} from sorted set. + * + * @param start + * @param end + * @return + * @see Redis Documentation: ZRANGE + */ Set range(long start, long end); - Set rangeByScore(double min, double max); - - Set reverseRange(long start, long end); - - Set 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 Redis Documentation: ZRANGE + */ Set> 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 Redis Documentation: ZRANGEBYSCORE + */ + Set 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 Redis Documentation: ZRANGEBYSCORE + */ Set> 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 Redis Documentation: ZREVRANGE + */ + Set 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 Redis Documentation: ZREVRANGE + */ Set> 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 Redis Documentation: ZREVRANGE + */ + Set 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 Redis Documentation: ZREVRANGEBYSCORE + */ Set> 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 Redis Documentation: ZCOUNT + */ + 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 Redis Documentation: ZCARD + */ + Long size(); + + /** + * Get the size of sorted set with the bound key. + * + * @return + * @since 1.3 + * @see Redis Documentation: ZCARD + */ + Long zCard(); + + /** + * Get the score of element with {@code value} from sorted set with key the bound key. + * + * @param o the value. + * @return + * @see Redis Documentation: ZREM + */ + 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 Redis Documentation: ZREMRANGEBYRANK + */ + 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 Redis Documentation: ZREMRANGEBYSCORE + */ + 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 Redis Documentation: ZUNIONSTORE + */ + 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 Redis Documentation: ZUNIONSTORE + */ + void unionAndStore(Collection 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 Redis Documentation: ZINTERSTORE + */ + 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 Redis Documentation: ZINTERSTORE + */ + void intersectAndStore(Collection otherKeys, K destKey); + + /** + * Iterate over elements in zset at the bound key.
+ * Important: Call {@link Cursor#close()} when done to avoid resource leak. + * + * @param options + * @return + * @since 1.4 + */ + Cursor> 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 Redis Documentation: ZRANGEBYLEX */ Set rangeByLex(Range range); @@ -67,58 +290,14 @@ public interface BoundZSetOperations extends BoundKeyOperations { * 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 Redis Documentation: ZRANGEBYLEX */ Set 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 otherKeys, K destKey); - - Boolean add(V value, double score); - - Long add(Set> 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> scan(ScanOptions options); + RedisOperations getOperations(); } diff --git a/src/main/java/org/springframework/data/redis/core/GeoOperations.java b/src/main/java/org/springframework/data/redis/core/GeoOperations.java index 6af23a44e..a7dc857b4 100644 --- a/src/main/java/org/springframework/data/redis/core/GeoOperations.java +++ b/src/main/java/org/springframework/data/redis/core/GeoOperations.java @@ -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 http://redis.io/commands#geo + * @author Mark Paluch + * @see Redis Documentation: Geo Commands * @since 1.8 */ public interface GeoOperations { @@ -43,7 +44,7 @@ public interface GeoOperations { * @param point must not be {@literal null}. * @param member must not be {@literal null}. * @return Number of elements added. - * @see http://redis.io/commands/geoadd + * @see Redis Documentation: GEOADD */ Long geoAdd(K key, Point point, M member); @@ -53,7 +54,7 @@ public interface GeoOperations { * @param key must not be {@literal null}. * @param location must not be {@literal null}. * @return Number of elements added. - * @see http://redis.io/commands/geoadd + * @see Redis Documentation: GEOADD */ Long geoAdd(K key, GeoLocation location); @@ -63,7 +64,7 @@ public interface GeoOperations { * @param key must not be {@literal null}. * @param memberCoordinateMap must not be {@literal null}. * @return Number of elements added. - * @see http://redis.io/commands/geoadd + * @see Redis Documentation: GEOADD */ Long geoAdd(K key, Map memberCoordinateMap); @@ -73,7 +74,7 @@ public interface GeoOperations { * @param key must not be {@literal null}. * @param locations must not be {@literal null}. * @return Number of elements added. - * @see http://redis.io/commands/geoadd + * @see Redis Documentation: GEOADD */ Long geoAdd(K key, Iterable> locations); @@ -84,7 +85,7 @@ public interface GeoOperations { * @param member1 must not be {@literal null}. * @param member2 must not be {@literal null}. * @return can be {@literal null}. - * @see http://redis.io/commands/geodist + * @see Redis Documentation: GEODIST */ Distance geoDist(K key, M member1, M member2); @@ -96,7 +97,7 @@ public interface GeoOperations { * @param member2 must not be {@literal null}. * @param metric must not be {@literal null}. * @return can be {@literal null}. - * @see http://redis.io/commands/geodist + * @see Redis Documentation: GEODIST */ Distance geoDist(K key, M member1, M member2, Metric metric); @@ -106,7 +107,7 @@ public interface GeoOperations { * @param key must not be {@literal null}. * @param members must not be {@literal null}. * @return never {@literal null}. - * @see http://redis.io/commands/geohash + * @see Redis Documentation: GEOHASH */ List geoHash(K key, M... members); @@ -116,7 +117,7 @@ public interface GeoOperations { * @param key must not be {@literal null}. * @param members must not be {@literal null}. * @return never {@literal null}. - * @see http://redis.io/commands/geopos + * @see Redis Documentation: GEOPOS */ List geoPos(K key, M... members); @@ -126,7 +127,7 @@ public interface GeoOperations { * @param key must not be {@literal null}. * @param within must not be {@literal null}. * @return never {@literal null}. - * @see http://redis.io/commands/georadius + * @see Redis Documentation: GEORADIUS */ GeoResults> geoRadius(K key, Circle within); @@ -137,7 +138,7 @@ public interface GeoOperations { * @param within must not be {@literal null}. * @param args must not be {@literal null}. * @return never {@literal null}. - * @see http://redis.io/commands/georadius + * @see Redis Documentation: GEORADIUS */ GeoResults> geoRadius(K key, Circle within, GeoRadiusCommandArgs args); @@ -149,7 +150,7 @@ public interface GeoOperations { * @param member must not be {@literal null}. * @param radius * @return never {@literal null}. - * @see http://redis.io/commands/georadiusbymember + * @see Redis Documentation: GEORADIUSBYMEMBER */ GeoResults> geoRadiusByMember(K key, M member, double radius); @@ -161,7 +162,7 @@ public interface GeoOperations { * @param member must not be {@literal null}. * @param distance must not be {@literal null}. * @return never {@literal null}. - * @see http://redis.io/commands/georadiusbymember + * @see Redis Documentation: GEORADIUSBYMEMBER */ GeoResults> geoRadiusByMember(K key, M member, Distance distance); @@ -174,7 +175,7 @@ public interface GeoOperations { * @param distance must not be {@literal null}. * @param args must not be {@literal null}. * @return never {@literal null}. - * @see http://redis.io/commands/georadiusbymember + * @see Redis Documentation: GEORADIUSBYMEMBER */ GeoResults> geoRadiusByMember(K key, M member, Distance distance, GeoRadiusCommandArgs args); diff --git a/src/main/java/org/springframework/data/redis/core/HashOperations.java b/src/main/java/org/springframework/data/redis/core/HashOperations.java index c5231bebf..911f956a5 100644 --- a/src/main/java/org/springframework/data/redis/core/HashOperations.java +++ b/src/main/java/org/springframework/data/redis/core/HashOperations.java @@ -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 { */ Map entries(H key); - /** - * @return - */ - RedisOperations getOperations(); - /** * Use a {@link Cursor} to iterate over entries in hash at {@code key}.
* Important: 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> scan(H key, ScanOptions options); + + /** + * @return + */ + RedisOperations getOperations(); } diff --git a/src/main/java/org/springframework/data/redis/core/ListOperations.java b/src/main/java/org/springframework/data/redis/core/ListOperations.java index e816bb2e1..49d0bebe2 100644 --- a/src/main/java/org/springframework/data/redis/core/ListOperations.java +++ b/src/main/java/org/springframework/data/redis/core/ListOperations.java @@ -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 { + /** + * 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 Redis Documentation: LRANGE + */ List 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 Redis Documentation: LTRIM + */ 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 Redis Documentation: LLEN + */ Long size(K key); + /** + * Prepend {@code value} to {@code key}. + * + * @param key must not be {@literal null}. + * @param value + * @return + * @see Redis Documentation: LPUSH + */ Long leftPush(K key, V value); + /** + * Prepend {@code values} to {@code key}. + * + * @param key must not be {@literal null}. + * @param values + * @return + * @see Redis Documentation: LPUSH + */ 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 Redis Documentation: LPUSH */ Long leftPushAll(K key, Collection values); + /** + * Prepend {@code values} to {@code key} only if the list exists. + * + * @param key must not be {@literal null}. + * @param value + * @return + * @see Redis Documentation: LPUSHX + */ 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 Redis Documentation: LPUSH + */ 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 Redis Documentation: RPUSH + */ Long rightPush(K key, V value); + /** + * Append {@code values} to {@code key}. + * + * @param key must not be {@literal null}. + * @param values + * @return + * @see Redis Documentation: RPUSH + */ 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 Redis Documentation: RPUSH */ Long rightPushAll(K key, Collection values); + /** + * Append {@code values} to {@code key} only if the list exists. + * + * @param key must not be {@literal null}. + * @param value + * @return + * @see Redis Documentation: RPUSHX + */ 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 Redis Documentation: RPUSH + */ 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 Redis Documentation: LSET + */ 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 Redis Documentation: LREM + */ + 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 Redis Documentation: LINDEX + */ 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 Redis Documentation: LPOP + */ V leftPop(K key); + /** + * Removes and returns first element from lists stored at {@code key} .
+ * Blocks connection 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 Redis Documentation: BLPOP + */ 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 Redis Documentation: RPOP + */ V rightPop(K key); + /** + * Removes and returns last element from lists stored at {@code key}.
+ * Blocks connection 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 Redis Documentation: BRPOP + */ 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 Redis Documentation: RPOPLPUSH + */ V rightPopAndLeftPush(K sourceKey, K destinationKey); + /** + * Remove the last element from list at {@code srcKey}, append it to {@code dstKey} and return its value.
+ * Blocks connection 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 Redis Documentation: BRPOPLPUSH + */ V rightPopAndLeftPush(K sourceKey, K destinationKey, long timeout, TimeUnit unit); RedisOperations getOperations(); diff --git a/src/main/java/org/springframework/data/redis/core/RedisOperations.java b/src/main/java/org/springframework/data/redis/core/RedisOperations.java index 7a8de0b86..6f05e830d 100644 --- a/src/main/java/org/springframework/data/redis/core/RedisOperations.java +++ b/src/main/java/org/springframework/data/redis/core/RedisOperations.java @@ -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 { @@ -141,53 +142,272 @@ public interface RedisOperations { */ T executeWithStickyConnection(RedisCallback callback); + // ------------------------------------------------------------------------- + // Methods dealing with Redis Keys + // ------------------------------------------------------------------------- + + /** + * Determine if given {@code key} exists. + * + * @param key must not be {@literal null}. + * @return + * @see Redis Documentation: EXISTS + */ Boolean hasKey(K key); + /** + * Delete given {@code key}. + * + * @param key must not be {@literal null}. + * @return The number of keys that were removed. + * @see Redis Documentation: DEL + */ void delete(K key); - void delete(Collection key); + /** + * Delete given {@code keys}. + * + * @param keys must not be {@literal null}. + * @return The number of keys that were removed. + * @see Redis Documentation: DEL + */ + void delete(Collection keys); + /** + * Determine the type stored at {@code key}. + * + * @param key must not be {@literal null}. + * @return + * @see Redis Documentation: TYPE + */ DataType type(K key); + /** + * Find all keys matching the given {@code pattern}. + * + * @param pattern must not be {@literal null}. + * @return + * @see Redis Documentation: KEYS + */ Set keys(K pattern); + /** + * Return a random key from the keyspace. + * + * @return + * @see Redis Documentation: RANDOMKEY + */ K randomKey(); + /** + * Rename key {@code oldKey} to {@code newKey}. + * + * @param oldKey must not be {@literal null}. + * @param newKey must not be {@literal null}. + * @see Redis Documentation: RENAME + */ 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 Redis Documentation: RENAMENX + */ 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 Redis Documentation: PERSIST + */ Boolean persist(K key); + /** + * Move given {@code key} to database with {@code index}. + * + * @param key must not be {@literal null}. + * @param dbIndex + * @return + * @see Redis Documentation: MOVE + */ 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 Redis Documentation: DUMP + */ 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 Redis Documentation: RESTORE + */ 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 Redis Documentation: TTL + */ 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 Redis Documentation: SORT + */ + List sort(SortQuery query); + /** + * Sort the elements for {@code query} applying {@link RedisSerializer}. + * + * @param query must not be {@literal null}. + * @return the deserialized results of sort. + * @see Redis Documentation: SORT + */ + List sort(SortQuery query, RedisSerializer resultSerializer); + + /** + * Sort the elements for {@code query} applying {@link BulkMapper}. + * + * @param query must not be {@literal null}. + * @return the deserialized results of sort. + * @see Redis Documentation: SORT + */ + List sort(SortQuery query, BulkMapper 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 Redis Documentation: SORT + */ + List sort(SortQuery query, BulkMapper bulkMapper, RedisSerializer 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 Redis Documentation: SORT + */ + Long sort(SortQuery 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 Redis Documentation: WATCH + */ + void watch(K key); + + /** + * Watch given {@code keys} for modifications during transaction started with {@link #multi()}. + * + * @param keys must not be {@literal null}. + * @see Redis Documentation: WATCH + */ void watch(Collection keys); + /** + * Flushes all the previously {@link #watch(Object)} keys. + * + * @see Redis Documentation: UNWATCH + */ void unwatch(); /** - * ' + * Mark the start of a transaction block.
+ * Commands will be queued and can then be executed by calling {@link #exec()} or rolled back using {@link #discard()} + *

+ * + * @see Redis Documentation: MULTI */ void multi(); + /** + * Discard all commands issued after {@link #multi()}. + * + * @see Redis Documentation: DISCARD + */ void discard(); + /** + * Executes all queued commands in a transaction started with {@link #multi()}.
+ * 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 Redis Documentation: EXEC + */ List 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 exec(RedisSerializer valueSerializer); + + // ------------------------------------------------------------------------- + // Methods dealing with Redis Server Commands + // ------------------------------------------------------------------------- + /** * /** Request information and statistics about connected clients. * @@ -197,19 +417,46 @@ public interface RedisOperations { List 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 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 Redis Documentation: SLAVEOF + */ + void slaveOf(String host, int port); + + /** + * Change server into master. + * + * @since 1.3 + * @see Redis Documentation: SLAVEOF + */ + 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 Redis Documentation: PUBLISH + */ 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 { */ ClusterOperations opsForCluster(); - List sort(SortQuery query); - - List sort(SortQuery query, RedisSerializer resultSerializer); - - List sort(SortQuery query, BulkMapper bulkMapper); - - List sort(SortQuery query, BulkMapper bulkMapper, RedisSerializer resultSerializer); - - Long sort(SortQuery 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(); } diff --git a/src/main/java/org/springframework/data/redis/core/SetOperations.java b/src/main/java/org/springframework/data/redis/core/SetOperations.java index 377cd1287..81cdcb269 100644 --- a/src/main/java/org/springframework/data/redis/core/SetOperations.java +++ b/src/main/java/org/springframework/data/redis/core/SetOperations.java @@ -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 { - Set difference(K key, K otherKey); - - Set difference(K key, Collection otherKeys); - - Long differenceAndStore(K key, K otherKey, K destKey); - - Long differenceAndStore(K key, Collection otherKeys, K destKey); - - Set intersect(K key, K otherKey); - - Set intersect(K key, Collection otherKeys); - - Long intersectAndStore(K key, K otherKey, K destKey); - - Long intersectAndStore(K key, Collection otherKeys, K destKey); - - Set union(K key, K otherKey); - - Set union(K key, Collection otherKeys); - - Long unionAndStore(K key, K otherKey, K destKey); - - Long unionAndStore(K key, Collection otherKeys, K destKey); - + /** + * Add given {@code values} to set at {@code key}. + * + * @param key must not be {@literal null}. + * @param values + * @return + * @see Redis Documentation: SADD + */ Long add(K key, V... values); - Boolean isMember(K key, Object o); - - Set members(K key); - - Boolean move(K key, V value, K destKey); - - V randomMember(K key); - - Set distinctRandomMembers(K key, long count); - - List 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 Redis Documentation: SREM + */ 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 Redis Documentation: SPOP + */ 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 Redis Documentation: SMOVE + */ + Boolean move(K key, V value, K destKey); + + /** + * Get size of set at {@code key}. + * + * @param key must not be {@literal null}. + * @return + * @see Redis Documentation: SCARD + */ Long size(K key); - RedisOperations getOperations(); + /** + * Check if set at {@code key} contains {@code value}. + * + * @param key must not be {@literal null}. + * @param o + * @return + * @see Redis Documentation: SISMEMBER + */ + 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 Redis Documentation: SINTER + */ + Set 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 Redis Documentation: SINTER + */ + Set intersect(K key, Collection 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 Redis Documentation: SINTERSTORE + */ + 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 Redis Documentation: SINTERSTORE + */ + Long intersectAndStore(K key, Collection 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 Redis Documentation: SUNION + */ + Set 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 Redis Documentation: SUNION + */ + Set union(K key, Collection 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 Redis Documentation: SUNIONSTORE + */ + 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 Redis Documentation: SUNIONSTORE + */ + Long unionAndStore(K key, Collection 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 Redis Documentation: SDIFF + */ + Set 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 Redis Documentation: SDIFF + */ + Set difference(K key, Collection 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 Redis Documentation: SDIFFSTORE + */ + 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 Redis Documentation: SDIFFSTORE + */ + Long differenceAndStore(K key, Collection otherKeys, K destKey); + + /** + * Get all elements of set at {@code key}. + * + * @param key must not be {@literal null}. + * @return + * @see Redis Documentation: SMEMBERS + */ + Set members(K key); + + /** + * Get random element from set at {@code key}. + * + * @param key must not be {@literal null}. + * @return + * @see Redis Documentation: SRANDMEMBER + */ + 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 Redis Documentation: SRANDMEMBER + */ + Set 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 Redis Documentation: SRANDMEMBER + */ + List randomMembers(K key, long count); /** * Iterate over elements in set at {@code key}.
* Important: Call {@link Cursor#close()} when done to avoid resource leak. * - * @since 1.4 * @param key * @param options * @return + * @since 1.4 */ Cursor scan(K key, ScanOptions options); + + RedisOperations getOperations(); } diff --git a/src/main/java/org/springframework/data/redis/core/ValueOperations.java b/src/main/java/org/springframework/data/redis/core/ValueOperations.java index 47ddf7cdd..c544e5219 100644 --- a/src/main/java/org/springframework/data/redis/core/ValueOperations.java +++ b/src/main/java/org/springframework/data/redis/core/ValueOperations.java @@ -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 { + /** + * Set {@code value} for {@code key}. + * + * @param key must not be {@literal null}. + * @param value + * @see Redis Documentation: SET + */ 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 Redis Documentation: SETEX */ 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 Redis Documentation: SETNX + */ Boolean setIfAbsent(K key, V value); - void multiSet(Map m); + /** + * Set multiple keys to multiple values using key-value pairs provided in {@code tuple}. + * + * @param map must not be {@literal null}. + * @see Redis Documentation: MSET + */ + void multiSet(Map map); - Boolean multiSetIfAbsent(Map 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 Redis Documentation: MSET + */ + Boolean multiSetIfAbsent(Map map); + /** + * Get the value of {@code key}. + * + * @param key must not be {@literal null}. + * @see Redis Documentation: GET + */ V get(Object key); + /** + * Set {@code value} of {@code key} and return its old value. + * + * @param key must not be {@literal null}. + * @see Redis Documentation: GETSET + */ 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 Redis Documentation: MGET + */ List multiGet(Collection 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 Redis Documentation: INCR + */ 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 Redis Documentation: INCRBYFLOAT + */ Double increment(K key, double delta); + /** + * Append a {@code value} to {@code key}. + * + * @param key must not be {@literal null}. + * @param value + * @see Redis Documentation: APPEND + */ 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 Redis Documentation: GETRANGE + */ 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 Redis Documentation: SETRANGE + */ 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 Redis Documentation: STRLEN + */ Long size(K key); - RedisOperations 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 Redis Documentation: SETBIT */ 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 Redis Documentation: GETBIT */ Boolean getBit(K key, long offset); - + + RedisOperations getOperations(); + } diff --git a/src/main/java/org/springframework/data/redis/core/ZSetOperations.java b/src/main/java/org/springframework/data/redis/core/ZSetOperations.java index f25fe4379..0bb69764a 100644 --- a/src/main/java/org/springframework/data/redis/core/ZSetOperations.java +++ b/src/main/java/org/springframework/data/redis/core/ZSetOperations.java @@ -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 { 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 Redis Documentation: ZADD + */ + Boolean add(K key, V value, double score); - Long intersectAndStore(K key, Collection 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 Redis Documentation: ZADD + */ + Long add(K key, Set> 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 Redis Documentation: ZREM + */ + Long remove(K key, Object... values); - Long unionAndStore(K key, Collection 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 Redis Documentation: ZINCRBY + */ + 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 Redis Documentation: ZRANK + */ + 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 Redis Documentation: ZREVRANK + */ + 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 Redis Documentation: ZRANGE + */ Set range(K key, long start, long end); - Set 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 Redis Documentation: ZRANGE + */ Set> 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 Redis Documentation: ZRANGEBYSCORE + */ + Set 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 Redis Documentation: ZRANGEBYSCORE + */ + Set> 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 Redis Documentation: ZRANGEBYSCORE + */ + Set 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 Redis Documentation: ZRANGEBYSCORE + */ + Set> 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 Redis Documentation: ZREVRANGE + */ + Set 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 Redis Documentation: ZREVRANGE + */ Set> 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 Redis Documentation: ZREVRANGE + */ + Set 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 Redis Documentation: ZREVRANGEBYSCORE + */ + Set> 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 Redis Documentation: ZREVRANGEBYSCORE + */ + Set 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 Redis Documentation: ZREVRANGEBYSCORE + */ + Set> 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 Redis Documentation: ZCOUNT + */ + 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 Redis Documentation: ZCARD + */ + 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 Redis Documentation: ZCARD + */ + 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 Redis Documentation: ZREM + */ + 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 Redis Documentation: ZREMRANGEBYRANK + */ + 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 Redis Documentation: ZREMRANGEBYSCORE + */ + 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 Redis Documentation: ZUNIONSTORE + */ + 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 Redis Documentation: ZUNIONSTORE + */ + Long unionAndStore(K key, Collection 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 Redis Documentation: ZINTERSTORE + */ + 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 Redis Documentation: ZINTERSTORE + */ + Long intersectAndStore(K key, Collection otherKeys, K destKey); + + /** + * Iterate over elements in zset at {@code key}.
+ * Important: Call {@link Cursor#close()} when done to avoid resource leak. + * + * @param key + * @param options + * @return + * @since 1.4 + */ + Cursor> 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 Redis Documentation: ZRANGEBYLEX */ Set rangeByLex(K key, Range range); @@ -70,79 +380,15 @@ public interface ZSetOperations { * 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 Redis Documentation: ZRANGEBYLEX */ Set rangeByLex(K key, Range range, Limit limit); - Set rangeByScore(K key, double min, double max); - - Set rangeByScore(K key, double min, double max, long offset, long count); - - Set reverseRangeByScore(K key, double min, double max); - - Set reverseRangeByScore(K key, double min, double max, long offset, long count); - - Set> rangeByScoreWithScores(K key, double min, double max); - - Set> rangeByScoreWithScores(K key, double min, double max, long offset, long count); - - Set> reverseRangeByScoreWithScores(K key, double min, double max); - - Set> reverseRangeByScoreWithScores(K key, double min, double max, long offset, long count); - - Boolean add(K key, V value, double score); - - Long add(K key, Set> 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 getOperations(); - - /** - * Iterate over elements in zset at {@code key}.
- * Important: Call {@link Cursor#close()} when done to avoid resource leak. - * - * @since 1.4 - * @param key - * @param options - * @return - */ - Cursor> scan(K key, ScanOptions options); }