diff --git a/Makefile b/Makefile
index 761d033..a5328e2 100644
--- a/Makefile
+++ b/Makefile
@@ -6,6 +6,7 @@ pidfile /tmp/redis1.pid
logfile /tmp/redis1.log
save ""
appendonly no
+client-output-buffer-limit pubsub 256k 128k 5
endef
define REDIS2_CONF
@@ -37,6 +38,7 @@ pidfile /tmp/redis4.pid
logfile /tmp/redis4.log
save ""
appendonly no
+slaveof localhost 6381
endef
define REDIS5_CONF
@@ -48,8 +50,22 @@ pidfile /tmp/redis5.pid
logfile /tmp/redis5.log
save ""
appendonly no
+slaveof localhost 6381
endef
+define REDIS6_CONF
+daemonize yes
+port 6384
+requirepass foobared
+masterauth foobared
+pidfile /tmp/redis6.pid
+logfile /tmp/redis6.log
+save ""
+appendonly no
+slaveof localhost 6379
+endef
+
+# SENTINELS
define REDIS_SENTINEL1
port 26379
daemonize yes
@@ -57,7 +73,6 @@ sentinel monitor mymaster 127.0.0.1 6379 1
sentinel auth-pass mymaster foobared
sentinel down-after-milliseconds mymaster 3000
sentinel failover-timeout mymaster 900000
-sentinel can-failover mymaster yes
sentinel parallel-syncs mymaster 1
pidfile /tmp/sentinel1.pid
logfile /tmp/sentinel1.log
@@ -69,7 +84,6 @@ daemonize yes
sentinel monitor mymaster 127.0.0.1 6381 2
sentinel auth-pass mymaster foobared
sentinel down-after-milliseconds mymaster 3000
-sentinel can-failover mymaster yes
sentinel parallel-syncs mymaster 1
sentinel failover-timeout mymaster 900000
pidfile /tmp/sentinel2.pid
@@ -82,31 +96,78 @@ daemonize yes
sentinel monitor mymaster 127.0.0.1 6381 2
sentinel auth-pass mymaster foobared
sentinel down-after-milliseconds mymaster 3000
-sentinel can-failover mymaster yes
sentinel parallel-syncs mymaster 1
sentinel failover-timeout mymaster 900000
pidfile /tmp/sentinel3.pid
logfile /tmp/sentinel3.log
endef
+# CLUSTER REDIS NODES
+define REDIS_CLUSTER_NODE1_CONF
+daemonize yes
+port 7379
+pidfile /tmp/redis_cluster_node1.pid
+logfile /tmp/redis_cluster_node1.log
+save ""
+appendonly no
+cluster-enabled yes
+cluster-config-file /tmp/redis_cluster_node1.conf
+endef
+
+define REDIS_CLUSTER_NODE2_CONF
+daemonize yes
+port 7380
+pidfile /tmp/redis_cluster_node2.pid
+logfile /tmp/redis_cluster_node2.log
+save ""
+appendonly no
+cluster-enabled yes
+cluster-config-file /tmp/redis_cluster_node2.conf
+endef
+
+define REDIS_CLUSTER_NODE3_CONF
+daemonize yes
+port 7381
+pidfile /tmp/redis_cluster_node3.pid
+logfile /tmp/redis_cluster_node3.log
+save ""
+appendonly no
+cluster-enabled yes
+cluster-config-file /tmp/redis_cluster_node3.conf
+endef
+
export REDIS1_CONF
export REDIS2_CONF
export REDIS3_CONF
export REDIS4_CONF
export REDIS5_CONF
+export REDIS6_CONF
export REDIS_SENTINEL1
export REDIS_SENTINEL2
export REDIS_SENTINEL3
+export REDIS_CLUSTER_NODE1_CONF
+export REDIS_CLUSTER_NODE2_CONF
+export REDIS_CLUSTER_NODE3_CONF
-start:
+start: cleanup
echo "$$REDIS1_CONF" | redis-server -
echo "$$REDIS2_CONF" | redis-server -
echo "$$REDIS3_CONF" | redis-server -
echo "$$REDIS4_CONF" | redis-server -
echo "$$REDIS5_CONF" | redis-server -
- echo "$$REDIS_SENTINEL1" | redis-server - --sentinel
- echo "$$REDIS_SENTINEL2" | redis-server - --sentinel
- echo "$$REDIS_SENTINEL3" | redis-server - --sentinel
+ echo "$$REDIS6_CONF" | redis-server -
+ echo "$$REDIS_SENTINEL1" > /tmp/sentinel1.conf && redis-server /tmp/sentinel1.conf --sentinel
+ @sleep 0.5
+ echo "$$REDIS_SENTINEL2" > /tmp/sentinel2.conf && redis-server /tmp/sentinel2.conf --sentinel
+ @sleep 0.5
+ echo "$$REDIS_SENTINEL3" > /tmp/sentinel3.conf && redis-server /tmp/sentinel3.conf --sentinel
+ echo "$$REDIS_CLUSTER_NODE1_CONF" | redis-server -
+ echo "$$REDIS_CLUSTER_NODE2_CONF" | redis-server -
+ echo "$$REDIS_CLUSTER_NODE3_CONF" | redis-server -
+
+cleanup:
+ - rm -vf /tmp/redis_cluster_node*.conf 2>/dev/null
+ - rm dump.rdb appendonly.aof - 2>/dev/null
stop:
kill `cat /tmp/redis1.pid`
@@ -115,76 +176,33 @@ stop:
kill `cat /tmp/redis3.pid` || true
kill `cat /tmp/redis4.pid` || true
kill `cat /tmp/redis5.pid` || true
+ kill `cat /tmp/redis6.pid` || true
kill `cat /tmp/sentinel1.pid`
kill `cat /tmp/sentinel2.pid`
kill `cat /tmp/sentinel3.pid`
+ kill `cat /tmp/redis_cluster_node1.pid` || true
+ kill `cat /tmp/redis_cluster_node2.pid` || true
+ kill `cat /tmp/redis_cluster_node3.pid` || true
+ rm -f /tmp/redis_cluster_node1.conf
+ rm -f /tmp/redis_cluster_node2.conf
+ rm -f /tmp/redis_cluster_node3.conf
test:
- echo "$$REDIS1_CONF" | redis-server -
- echo "$$REDIS2_CONF" | redis-server -
- echo "$$REDIS3_CONF" | redis-server -
- echo "$$REDIS4_CONF" | redis-server -
- echo "$$REDIS5_CONF" | redis-server -
- echo "$$REDIS_SENTINEL1" | redis-server - --sentinel
- echo "$$REDIS_SENTINEL2" | redis-server - --sentinel
- echo "$$REDIS_SENTINEL3" | redis-server - --sentinel
-
- mvn clean compile test
-
- kill `cat /tmp/redis1.pid`
- kill `cat /tmp/redis2.pid`
- # this get's segfaulted by the tests
- kill `cat /tmp/redis3.pid` || true
- kill `cat /tmp/redis4.pid` || true
- kill `cat /tmp/redis5.pid` || true
- kill `cat /tmp/sentinel1.pid`
- kill `cat /tmp/sentinel2.pid`
- kill `cat /tmp/sentinel3.pid`
+ make start
+ sleep 2
+ mvn -Dtest=${TEST} clean compile test
+ make stop
deploy:
- echo "$$REDIS1_CONF" | redis-server -
- echo "$$REDIS2_CONF" | redis-server -
- echo "$$REDIS3_CONF" | redis-server -
- echo "$$REDIS4_CONF" | redis-server -
- echo "$$REDIS5_CONF" | redis-server -
- echo "$$REDIS_SENTINEL1" | redis-server - --sentinel
- echo "$$REDIS_SENTINEL2" | redis-server - --sentinel
- echo "$$REDIS_SENTINEL3" | redis-server - --sentinel
-
+ make start
mvn clean deploy
-
- kill `cat /tmp/redis1.pid`
- kill `cat /tmp/redis2.pid`
- # this get's segfaulted by the tests
- kill `cat /tmp/redis3.pid` || true
- kill `cat /tmp/redis4.pid` || true
- kill `cat /tmp/redis5.pid` || true
- kill `cat /tmp/sentinel1.pid`
- kill `cat /tmp/sentinel2.pid`
- kill `cat /tmp/sentinel3.pid`
+ make stop
release:
- echo "$$REDIS1_CONF" | redis-server -
- echo "$$REDIS2_CONF" | redis-server -
- echo "$$REDIS3_CONF" | redis-server -
- echo "$$REDIS4_CONF" | redis-server -
- echo "$$REDIS5_CONF" | redis-server -
- echo "$$REDIS_SENTINEL1" | redis-server - --sentinel
- echo "$$REDIS_SENTINEL2" | redis-server - --sentinel
- echo "$$REDIS_SENTINEL3" | redis-server - --sentinel
-
+ make start
mvn release:clean
mvn release:prepare
mvn release:perform
-
- kill `cat /tmp/redis1.pid`
- kill `cat /tmp/redis2.pid`
- # this get's segfaulted by the tests
- kill `cat /tmp/redis3.pid` || true
- kill `cat /tmp/redis4.pid` || true
- kill `cat /tmp/redis5.pid` || true
- kill `cat /tmp/sentinel1.pid`
- kill `cat /tmp/sentinel2.pid`
- kill `cat /tmp/sentinel3.pid`
+ make stop
.PHONY: test
diff --git a/README.md b/README.md
index 3b2a7db..ac3c67d 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@ Jedis is a blazingly small and sane [Redis](http://github.com/antirez/redis "Red
Jedis was conceived to be EASY to use.
-Jedis is fully compatible with redis 2.6.14.
+Jedis is fully compatible with redis 2.8.5.
## Community
@@ -33,6 +33,7 @@ All of the following redis features are supported:
- Key-tags for sharding
- Sharding with pipelining
- Scripting with pipelining
+- Redis Cluster
## How do I use it?
@@ -45,7 +46,7 @@ Or use it as a maven dependency:
redis.clients
jedis
- 2.0.0
+ 2.2.1
jar
compile
@@ -65,6 +66,19 @@ Please check the [wiki](http://github.com/xetorthio/jedis/wiki "wiki"). There ar
And you are done!
+## Jedis Cluster
+
+Redis cluster [specification](http://redis.io/topics/cluster-spec) (still under development) is implemented
+
+```java
+Set jedisClusterNodes = new HashSet();
+//Jedis Cluster will attempt to discover cluster nodes automatically
+jedisClusterNodes.add(new HostAndPort("127.0.0.1", 7379));
+JedisCluster jc = new JedisCluster(jedisClusterNode);
+jc.set("foo", "bar");
+String value = jc.get("foo");
+```
+
## I want to contribute!
That is great! Just fork the project in github. Create a topic branch, write some code, and add some tests for your new code.
diff --git a/build.gradle b/build.gradle
index e9076f3..30af731 100644
--- a/build.gradle
+++ b/build.gradle
@@ -11,8 +11,8 @@ repositories {
}
dependencies {
- testCompile 'junit:junit:4.8.1'
- compile 'commons-pool:commons-pool:1.5.5'
+ testCompile 'junit:junit:4.11'
+ compile 'org.apache.commons:commons-pool2:2.0'
}
@@ -28,6 +28,6 @@ uploadArchives {
*/
task createWrapper(type: Wrapper) {
- gradleVersion = '1.0-milestone-6'
+ gradleVersion = '1.8'
}
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 45bfb5c..667288a 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index b3e777e..cf32f33 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Fri Dec 23 12:54:50 CST 2011
+#Mon Nov 04 18:13:13 EST 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=http\://repo.gradle.org/gradle/distributions/gradle-1.0-milestone-6-bin.zip
+distributionUrl=http\://services.gradle.org/distributions/gradle-1.8-bin.zip
diff --git a/gradlew b/gradlew
index d8809f1..91a7e26 100755
--- a/gradlew
+++ b/gradlew
@@ -1,16 +1,16 @@
-#!/bin/bash
+#!/usr/bin/env bash
##############################################################################
-## ##
-## Gradle wrapper script for UN*X ##
-## ##
+##
+## Gradle start up script for UN*X
+##
##############################################################################
-# Uncomment those lines to set JVM options. GRADLE_OPTS and JAVA_OPTS can be used together.
-# GRADLE_OPTS="$GRADLE_OPTS -Xmx512m"
-# JAVA_OPTS="$JAVA_OPTS -Xmx512m"
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
-GRADLE_APP_NAME=Gradle
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
@@ -42,54 +42,51 @@ case "`uname`" in
;;
esac
-# Attempt to set JAVA_HOME if it's not already set.
-if [ -z "$JAVA_HOME" ] ; then
- if $darwin ; then
- [ -z "$JAVA_HOME" -a -d "/Library/Java/Home" ] && export JAVA_HOME="/Library/Java/Home"
- [ -z "$JAVA_HOME" -a -d "/System/Library/Frameworks/JavaVM.framework/Home" ] && export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Home"
- else
- javaExecutable="`which javac`"
- [ -z "$javaExecutable" -o "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ] && die "JAVA_HOME not set and cannot find javac to deduce location, please set JAVA_HOME."
- # readlink(1) is not available as standard on Solaris 10.
- readLink=`which readlink`
- [ `expr "$readLink" : '\([^ ]*\)'` = "no" ] && die "JAVA_HOME not set and readlink not available, please set JAVA_HOME."
- javaExecutable="`readlink -f \"$javaExecutable\"`"
- javaHome="`dirname \"$javaExecutable\"`"
- javaHome=`expr "$javaHome" : '\(.*\)/bin'`
- export JAVA_HOME="$javaHome"
- fi
-fi
-
# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
- [ -n "$JAVACMD" ] && JAVACMD=`cygpath --unix "$JAVACMD"`
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
-STARTER_MAIN_CLASS=org.gradle.wrapper.GradleWrapperMain
-CLASSPATH=`dirname "$0"`/gradle/wrapper/gradle-wrapper.jar
-WRAPPER_PROPERTIES=`dirname "$0"`/gradle/wrapper/gradle-wrapper.properties
-# Determine the Java command to use to start the JVM.
-if [ -z "$JAVACMD" ] ; then
- if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
else
- JAVACMD="java"
+ PRG=`dirname "$PRG"`"/$link"
fi
-fi
-if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >&-
+APP_HOME="`pwd -P`"
+cd "$SAVED" >&-
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
-fi
-if [ -z "$JAVA_HOME" ] ; then
- warn "JAVA_HOME environment variable is not set"
fi
# Increase the maximum file descriptors if we can.
@@ -104,19 +101,18 @@ if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
- warn "Could not query businessSystem maximum file descriptor limit: $MAX_FD_LIMIT"
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
-# For Darwin, add GRADLE_APP_NAME to the JAVA_OPTS as -Xdock:name
+# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
- JAVA_OPTS="$JAVA_OPTS -Xdock:name=$GRADLE_APP_NAME"
-# we may also want to set -Xdock:image
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
- JAVA_HOME=`cygpath --path --mixed "$JAVA_HOME"`
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
# We build the pattern for arguments to be converted via cygpath
@@ -143,7 +139,7 @@ if $cygwin ; then
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
- done
+ done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
@@ -158,11 +154,11 @@ if $cygwin ; then
esac
fi
-GRADLE_APP_BASE_NAME=`basename "$0"`
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
-exec "$JAVACMD" $JAVA_OPTS $GRADLE_OPTS \
- -classpath "$CLASSPATH" \
- -Dorg.gradle.appname="$GRADLE_APP_BASE_NAME" \
- -Dorg.gradle.wrapper.properties="$WRAPPER_PROPERTIES" \
- $STARTER_MAIN_CLASS \
- "$@"
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/gradlew.bat b/gradlew.bat
index 4855abb..aec9973 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -1,24 +1,37 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
-@rem ##
-@rem Gradle startup script for Windows ##
-@rem ##
+@rem
+@rem Gradle startup script for Windows
+@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
-@rem Uncomment those lines to set JVM options. GRADLE_OPTS and JAVA_OPTS can be used together.
-@rem set GRADLE_OPTS=%GRADLE_OPTS% -Xmx512m
-@rem set JAVA_OPTS=%JAVA_OPTS% -Xmx512m
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.\
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
@rem Find java.exe
-set JAVA_EXE=java.exe
-if not defined JAVA_HOME goto init
+if defined JAVA_HOME goto findJavaFromJavaHome
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
@@ -29,14 +42,14 @@ echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
-echo.
-goto end
+
+goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
-if "%eval[2+2]" == "4" goto 4NT_args
+if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
@@ -56,27 +69,22 @@ set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
-set STARTER_MAIN_CLASS=org.gradle.wrapper.GradleWrapperMain
-set CLASSPATH=%DIRNAME%\gradle\wrapper\gradle-wrapper.jar
-set WRAPPER_PROPERTIES=%DIRNAME%\gradle\wrapper\gradle-wrapper.properties
-
-set GRADLE_OPTS=%JAVA_OPTS% %GRADLE_OPTS% -Dorg.gradle.wrapper.properties="%WRAPPER_PROPERTIES%"
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
-"%JAVA_EXE%" %GRADLE_OPTS% -classpath "%CLASSPATH%" %STARTER_MAIN_CLASS% %CMD_LINE_ARGS%
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
-if not "%OS%"=="Windows_NT" echo 1 > nul | choice /n /c:1
-
+:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit "%ERRORLEVEL%"
-exit /b "%ERRORLEVEL%"
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
-:omega
\ No newline at end of file
+:omega
diff --git a/pom.xml b/pom.xml
index bb63109..c2c7766 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
jar
redis.clients
jedis
- 2.2.2-SNAPSHOT
+ 2.3.2-SNAPSHOT
Jedis
Jedis is a blazingly small and sane Redis java client.
https://github.com/xetorthio/jedis
@@ -45,9 +45,10 @@
- localhost:6379,localhost:6380,localhost:6381,localhost:6382,localhost:6383
- localhost:26379,localhost:26380
- github
+ localhost:6379,localhost:6380,localhost:6381,localhost:6382,localhost:6383,localhost:6384
+ localhost:26379,localhost:26380,localhost:26381
+ localhost:7379,localhost:7380,localhost:7381
+ github
@@ -59,9 +60,9 @@
test
- commons-pool
- commons-pool
- 1.6
+ org.apache.commons
+ commons-pool2
+ 2.0
jar
compile
@@ -115,11 +116,11 @@
org.apache.maven.plugins
maven-release-plugin
- 2.4.1
+ 2.4.2
maven-deploy-plugin
- 2.7
+ 2.8.1
internal.repo::default::file://${project.build.directory}/mvn-repo
diff --git a/src/main/java/redis/clients/jedis/AdvancedBinaryJedisCommands.java b/src/main/java/redis/clients/jedis/AdvancedBinaryJedisCommands.java
index 51b4879..224dd11 100644
--- a/src/main/java/redis/clients/jedis/AdvancedBinaryJedisCommands.java
+++ b/src/main/java/redis/clients/jedis/AdvancedBinaryJedisCommands.java
@@ -1,6 +1,5 @@
package redis.clients.jedis;
-
import java.util.List;
public interface AdvancedBinaryJedisCommands {
diff --git a/src/main/java/redis/clients/jedis/AdvancedJedisCommands.java b/src/main/java/redis/clients/jedis/AdvancedJedisCommands.java
index 5ed50eb..45e825b 100644
--- a/src/main/java/redis/clients/jedis/AdvancedJedisCommands.java
+++ b/src/main/java/redis/clients/jedis/AdvancedJedisCommands.java
@@ -1,9 +1,8 @@
package redis.clients.jedis;
-import redis.clients.util.Slowlog;
-
import java.util.List;
+import redis.clients.util.Slowlog;
public interface AdvancedJedisCommands {
List configGet(String pattern);
diff --git a/src/main/java/redis/clients/jedis/BasicCommands.java b/src/main/java/redis/clients/jedis/BasicCommands.java
index 482d43b..c201e41 100644
--- a/src/main/java/redis/clients/jedis/BasicCommands.java
+++ b/src/main/java/redis/clients/jedis/BasicCommands.java
@@ -27,7 +27,7 @@ public interface BasicCommands {
String shutdown();
String info();
-
+
String info(String section);
String slaveof(String host, int port);
@@ -39,4 +39,6 @@ public interface BasicCommands {
String debug(DebugParams params);
String configResetStat();
+
+ Long waitReplicas(int replicas, long timeout);
}
diff --git a/src/main/java/redis/clients/jedis/BasicRedisPipeline.java b/src/main/java/redis/clients/jedis/BasicRedisPipeline.java
index 97658d8..bec6e8c 100644
--- a/src/main/java/redis/clients/jedis/BasicRedisPipeline.java
+++ b/src/main/java/redis/clients/jedis/BasicRedisPipeline.java
@@ -1,8 +1,5 @@
package redis.clients.jedis;
-
-import java.util.List;
-
/**
* Pipelined responses for all of the low level, non key related commands
*/
diff --git a/src/main/java/redis/clients/jedis/BinaryClient.java b/src/main/java/redis/clients/jedis/BinaryClient.java
index acb120b..26cd8f2 100644
--- a/src/main/java/redis/clients/jedis/BinaryClient.java
+++ b/src/main/java/redis/clients/jedis/BinaryClient.java
@@ -1,22 +1,26 @@
package redis.clients.jedis;
-import redis.clients.jedis.Protocol.Command;
-import redis.clients.jedis.Protocol.Keyword;
-import redis.clients.util.SafeEncoder;
+import static redis.clients.jedis.Protocol.toByteArray;
+import static redis.clients.jedis.Protocol.Command.*;
+import static redis.clients.jedis.Protocol.Keyword.ENCODING;
+import static redis.clients.jedis.Protocol.Keyword.IDLETIME;
+import static redis.clients.jedis.Protocol.Keyword.LEN;
+import static redis.clients.jedis.Protocol.Keyword.LIMIT;
+import static redis.clients.jedis.Protocol.Keyword.NO;
+import static redis.clients.jedis.Protocol.Keyword.ONE;
+import static redis.clients.jedis.Protocol.Keyword.REFCOUNT;
+import static redis.clients.jedis.Protocol.Keyword.RESET;
+import static redis.clients.jedis.Protocol.Keyword.STORE;
+import static redis.clients.jedis.Protocol.Keyword.WITHSCORES;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import static redis.clients.jedis.Protocol.Command.*;
-import static redis.clients.jedis.Protocol.Command.EXISTS;
-import static redis.clients.jedis.Protocol.Command.PSUBSCRIBE;
-import static redis.clients.jedis.Protocol.Command.PUNSUBSCRIBE;
-import static redis.clients.jedis.Protocol.Command.SUBSCRIBE;
-import static redis.clients.jedis.Protocol.Command.UNSUBSCRIBE;
-import static redis.clients.jedis.Protocol.Keyword.*;
-import static redis.clients.jedis.Protocol.toByteArray;
+import redis.clients.jedis.Protocol.Command;
+import redis.clients.jedis.Protocol.Keyword;
+import redis.clients.util.SafeEncoder;
public class BinaryClient extends Connection {
public enum LIST_POSITION {
@@ -34,10 +38,16 @@ public class BinaryClient extends Connection {
private long db;
+ private boolean isInWatch;
+
public boolean isInMulti() {
return isInMulti;
}
+ public boolean isInWatch() {
+ return isInWatch;
+ }
+
public BinaryClient(final String host) {
super(host);
}
@@ -82,11 +92,11 @@ public class BinaryClient extends Connection {
sendCommand(Command.SET, key, value);
}
- public void set(final byte[] key, final byte[] value, final byte[] nxxx, final byte[] expx, final long time) {
- sendCommand(Command.SET, key, value, nxxx, expx, toByteArray(time));
+ public void set(final byte[] key, final byte[] value, final byte[] nxxx,
+ final byte[] expx, final long time) {
+ sendCommand(Command.SET, key, value, nxxx, expx, toByteArray(time));
}
-
public void get(final byte[] key) {
sendCommand(Command.GET, key);
}
@@ -377,15 +387,16 @@ public class BinaryClient extends Connection {
sendCommand(ZADD, key, toByteArray(score), member);
}
- public void zaddBinary(final byte[] key, Map scoreMembers) {
+ public void zaddBinary(final byte[] key,
+ final Map scoreMembers) {
+
ArrayList args = new ArrayList(
scoreMembers.size() * 2 + 1);
-
args.add(key);
- for (Map.Entry entry : scoreMembers.entrySet()) {
- args.add(toByteArray(entry.getKey()));
- args.add(entry.getValue());
+ for (Map.Entry entry : scoreMembers.entrySet()) {
+ args.add(toByteArray(entry.getValue()));
+ args.add(entry.getKey());
}
byte[][] argsArray = new byte[args.size()][];
@@ -447,19 +458,23 @@ public class BinaryClient extends Connection {
public void discard() {
sendCommand(DISCARD);
isInMulti = false;
+ isInWatch = false;
}
public void exec() {
sendCommand(EXEC);
isInMulti = false;
+ isInWatch = false;
}
public void watch(final byte[]... keys) {
sendCommand(WATCH, keys);
+ isInWatch = true;
}
public void unwatch() {
sendCommand(UNWATCH);
+ isInWatch = false;
}
public void sort(final byte[] key) {
@@ -476,14 +491,14 @@ public class BinaryClient extends Connection {
public void blpop(final byte[][] args) {
sendCommand(BLPOP, args);
}
-
+
public void blpop(final int timeout, final byte[]... keys) {
- final List args = new ArrayList();
- for (final byte[] arg : keys) {
- args.add(arg);
- }
- args.add(Protocol.toByteArray(timeout));
- blpop(args.toArray(new byte[args.size()][]));
+ final List args = new ArrayList();
+ for (final byte[] arg : keys) {
+ args.add(arg);
+ }
+ args.add(Protocol.toByteArray(timeout));
+ blpop(args.toArray(new byte[args.size()][]));
}
public void sort(final byte[] key, final SortingParams sortingParameters,
@@ -503,14 +518,14 @@ public class BinaryClient extends Connection {
public void brpop(final byte[][] args) {
sendCommand(BRPOP, args);
}
-
+
public void brpop(final int timeout, final byte[]... keys) {
- final List args = new ArrayList();
- for (final byte[] arg : keys) {
- args.add(arg);
- }
- args.add(Protocol.toByteArray(timeout));
- brpop(args.toArray(new byte[args.size()][]));
+ final List args = new ArrayList();
+ for (final byte[] arg : keys) {
+ args.add(arg);
+ }
+ args.add(Protocol.toByteArray(timeout));
+ brpop(args.toArray(new byte[args.size()][]));
}
public void auth(final String password) {
@@ -543,32 +558,39 @@ public class BinaryClient extends Connection {
}
public void punsubscribe(final byte[]... patterns) {
- sendCommand(PUNSUBSCRIBE, patterns);
+ sendCommand(PUNSUBSCRIBE, patterns);
+ }
+
+ public void pubsub(final byte[]... args) {
+ sendCommand(PUBSUB, args);
}
-
public void zcount(final byte[] key, final double min, final double max) {
- byte byteArrayMin[] = (min == Double.NEGATIVE_INFINITY) ? "-inf".getBytes() : toByteArray(min);
- byte byteArrayMax[] = (max == Double.POSITIVE_INFINITY) ? "+inf".getBytes() : toByteArray(max);
+ byte byteArrayMin[] = (min == Double.NEGATIVE_INFINITY) ? "-inf"
+ .getBytes() : toByteArray(min);
+ byte byteArrayMax[] = (max == Double.POSITIVE_INFINITY) ? "+inf"
+ .getBytes() : toByteArray(max);
- sendCommand(ZCOUNT, key, byteArrayMin, byteArrayMax);
+ sendCommand(ZCOUNT, key, byteArrayMin, byteArrayMax);
}
public void zcount(final byte[] key, final byte min[], final byte max[]) {
- sendCommand(ZCOUNT, key, min, max);
+ sendCommand(ZCOUNT, key, min, max);
}
public void zcount(final byte[] key, final String min, final String max) {
- sendCommand(ZCOUNT, key, min.getBytes(), max.getBytes());
+ sendCommand(ZCOUNT, key, min.getBytes(), max.getBytes());
}
public void zrangeByScore(final byte[] key, final double min,
- final double max) {
+ final double max) {
- byte byteArrayMin[] = (min == Double.NEGATIVE_INFINITY) ? "-inf".getBytes() : toByteArray(min);
- byte byteArrayMax[] = (max == Double.POSITIVE_INFINITY) ? "+inf".getBytes() : toByteArray(max);
+ byte byteArrayMin[] = (min == Double.NEGATIVE_INFINITY) ? "-inf"
+ .getBytes() : toByteArray(min);
+ byte byteArrayMax[] = (max == Double.POSITIVE_INFINITY) ? "+inf"
+ .getBytes() : toByteArray(max);
- sendCommand(ZRANGEBYSCORE, key, byteArrayMin, byteArrayMax);
+ sendCommand(ZRANGEBYSCORE, key, byteArrayMin, byteArrayMax);
}
public void zrangeByScore(final byte[] key, final byte[] min,
@@ -577,17 +599,19 @@ public class BinaryClient extends Connection {
}
public void zrangeByScore(final byte[] key, final String min,
- final String max) {
- sendCommand(ZRANGEBYSCORE, key, min.getBytes(), max.getBytes());
+ final String max) {
+ sendCommand(ZRANGEBYSCORE, key, min.getBytes(), max.getBytes());
}
public void zrevrangeByScore(final byte[] key, final double max,
- final double min) {
+ final double min) {
- byte byteArrayMin[] = (min == Double.NEGATIVE_INFINITY) ? "-inf".getBytes() : toByteArray(min);
- byte byteArrayMax[] = (max == Double.POSITIVE_INFINITY) ? "+inf".getBytes() : toByteArray(max);
+ byte byteArrayMin[] = (min == Double.NEGATIVE_INFINITY) ? "-inf"
+ .getBytes() : toByteArray(min);
+ byte byteArrayMax[] = (max == Double.POSITIVE_INFINITY) ? "+inf"
+ .getBytes() : toByteArray(max);
- sendCommand(ZREVRANGEBYSCORE, key, byteArrayMax, byteArrayMin);
+ sendCommand(ZREVRANGEBYSCORE, key, byteArrayMax, byteArrayMin);
}
public void zrevrangeByScore(final byte[] key, final byte[] max,
@@ -596,114 +620,125 @@ public class BinaryClient extends Connection {
}
public void zrevrangeByScore(final byte[] key, final String max,
- final String min) {
- sendCommand(ZREVRANGEBYSCORE, key, max.getBytes(), min.getBytes());
+ final String min) {
+ sendCommand(ZREVRANGEBYSCORE, key, max.getBytes(), min.getBytes());
}
public void zrangeByScore(final byte[] key, final double min,
- final double max, final int offset, int count) {
+ final double max, final int offset, int count) {
- byte byteArrayMin[] = (min == Double.NEGATIVE_INFINITY) ? "-inf".getBytes() : toByteArray(min);
- byte byteArrayMax[] = (max == Double.POSITIVE_INFINITY) ? "+inf".getBytes() : toByteArray(max);
+ byte byteArrayMin[] = (min == Double.NEGATIVE_INFINITY) ? "-inf"
+ .getBytes() : toByteArray(min);
+ byte byteArrayMax[] = (max == Double.POSITIVE_INFINITY) ? "+inf"
+ .getBytes() : toByteArray(max);
- sendCommand(ZRANGEBYSCORE, key, byteArrayMin, byteArrayMax,
- LIMIT.raw, toByteArray(offset), toByteArray(count));
+ sendCommand(ZRANGEBYSCORE, key, byteArrayMin, byteArrayMax, LIMIT.raw,
+ toByteArray(offset), toByteArray(count));
}
-
- public void zrangeByScore(final byte[] key, final String min,
- final String max, final int offset, int count) {
- sendCommand(ZRANGEBYSCORE, key, min.getBytes(), max.getBytes(),
- LIMIT.raw, toByteArray(offset), toByteArray(count));
+ public void zrangeByScore(final byte[] key, final String min,
+ final String max, final int offset, int count) {
+
+ sendCommand(ZRANGEBYSCORE, key, min.getBytes(), max.getBytes(),
+ LIMIT.raw, toByteArray(offset), toByteArray(count));
}
public void zrevrangeByScore(final byte[] key, final double max,
- final double min, final int offset, int count) {
+ final double min, final int offset, int count) {
- byte byteArrayMin[] = (min == Double.NEGATIVE_INFINITY) ? "-inf".getBytes() : toByteArray(min);
- byte byteArrayMax[] = (max == Double.POSITIVE_INFINITY) ? "+inf".getBytes() : toByteArray(max);
+ byte byteArrayMin[] = (min == Double.NEGATIVE_INFINITY) ? "-inf"
+ .getBytes() : toByteArray(min);
+ byte byteArrayMax[] = (max == Double.POSITIVE_INFINITY) ? "+inf"
+ .getBytes() : toByteArray(max);
- sendCommand(ZREVRANGEBYSCORE, key, byteArrayMax, byteArrayMin,
- LIMIT.raw, toByteArray(offset), toByteArray(count));
- }
+ sendCommand(ZREVRANGEBYSCORE, key, byteArrayMax, byteArrayMin,
+ LIMIT.raw, toByteArray(offset), toByteArray(count));
+ }
public void zrevrangeByScore(final byte[] key, final String max,
- final String min, final int offset, int count) {
+ final String min, final int offset, int count) {
- sendCommand(ZREVRANGEBYSCORE, key, max.getBytes(), min.getBytes(),
- LIMIT.raw, toByteArray(offset), toByteArray(count));
+ sendCommand(ZREVRANGEBYSCORE, key, max.getBytes(), min.getBytes(),
+ LIMIT.raw, toByteArray(offset), toByteArray(count));
}
public void zrangeByScoreWithScores(final byte[] key, final double min,
- final double max) {
+ final double max) {
- byte byteArrayMin[] = (min == Double.NEGATIVE_INFINITY) ? "-inf".getBytes() : toByteArray(min);
- byte byteArrayMax[] = (max == Double.POSITIVE_INFINITY) ? "+inf".getBytes() : toByteArray(max);
+ byte byteArrayMin[] = (min == Double.NEGATIVE_INFINITY) ? "-inf"
+ .getBytes() : toByteArray(min);
+ byte byteArrayMax[] = (max == Double.POSITIVE_INFINITY) ? "+inf"
+ .getBytes() : toByteArray(max);
- sendCommand(ZRANGEBYSCORE, key, byteArrayMin, byteArrayMax,
- WITHSCORES.raw);
+ sendCommand(ZRANGEBYSCORE, key, byteArrayMin, byteArrayMax,
+ WITHSCORES.raw);
}
public void zrangeByScoreWithScores(final byte[] key, final String min,
- final String max) {
+ final String max) {
- sendCommand(ZRANGEBYSCORE, key, min.getBytes(), max.getBytes(),
- WITHSCORES.raw);
+ sendCommand(ZRANGEBYSCORE, key, min.getBytes(), max.getBytes(),
+ WITHSCORES.raw);
}
public void zrevrangeByScoreWithScores(final byte[] key, final double max,
- final double min) {
+ final double min) {
- byte byteArrayMin[] = (min == Double.NEGATIVE_INFINITY) ? "-inf".getBytes() : toByteArray(min);
- byte byteArrayMax[] = (max == Double.POSITIVE_INFINITY) ? "+inf".getBytes() : toByteArray(max);
+ byte byteArrayMin[] = (min == Double.NEGATIVE_INFINITY) ? "-inf"
+ .getBytes() : toByteArray(min);
+ byte byteArrayMax[] = (max == Double.POSITIVE_INFINITY) ? "+inf"
+ .getBytes() : toByteArray(max);
- sendCommand(ZREVRANGEBYSCORE, key, byteArrayMax, byteArrayMin,
- WITHSCORES.raw);
+ sendCommand(ZREVRANGEBYSCORE, key, byteArrayMax, byteArrayMin,
+ WITHSCORES.raw);
}
public void zrevrangeByScoreWithScores(final byte[] key, final String max,
- final String min) {
- sendCommand(ZREVRANGEBYSCORE, key, max.getBytes(), min.getBytes(),
- WITHSCORES.raw);
+ final String min) {
+ sendCommand(ZREVRANGEBYSCORE, key, max.getBytes(), min.getBytes(),
+ WITHSCORES.raw);
}
public void zrangeByScoreWithScores(final byte[] key, final double min,
- final double max, final int offset, final int count) {
+ final double max, final int offset, final int count) {
- byte byteArrayMin[] = (min == Double.NEGATIVE_INFINITY) ? "-inf".getBytes() : toByteArray(min);
- byte byteArrayMax[] = (max == Double.POSITIVE_INFINITY) ? "+inf".getBytes() : toByteArray(max);
+ byte byteArrayMin[] = (min == Double.NEGATIVE_INFINITY) ? "-inf"
+ .getBytes() : toByteArray(min);
+ byte byteArrayMax[] = (max == Double.POSITIVE_INFINITY) ? "+inf"
+ .getBytes() : toByteArray(max);
- sendCommand(ZRANGEBYSCORE, key, byteArrayMin, byteArrayMax,
- LIMIT.raw, toByteArray(offset), toByteArray(count),
- WITHSCORES.raw);
+ sendCommand(ZRANGEBYSCORE, key, byteArrayMin, byteArrayMax, LIMIT.raw,
+ toByteArray(offset), toByteArray(count), WITHSCORES.raw);
}
public void zrangeByScoreWithScores(final byte[] key, final String min,
- final String max, final int offset, final int count) {
- sendCommand(ZRANGEBYSCORE, key, min.getBytes(), max.getBytes(),
- LIMIT.raw, toByteArray(offset), toByteArray(count),
- WITHSCORES.raw);
+ final String max, final int offset, final int count) {
+ sendCommand(ZRANGEBYSCORE, key, min.getBytes(), max.getBytes(),
+ LIMIT.raw, toByteArray(offset), toByteArray(count),
+ WITHSCORES.raw);
}
public void zrevrangeByScoreWithScores(final byte[] key, final double max,
- final double min, final int offset, final int count) {
+ final double min, final int offset, final int count) {
- byte byteArrayMin[] = (min == Double.NEGATIVE_INFINITY) ? "-inf".getBytes() : toByteArray(min);
- byte byteArrayMax[] = (max == Double.POSITIVE_INFINITY) ? "+inf".getBytes() : toByteArray(max);
+ byte byteArrayMin[] = (min == Double.NEGATIVE_INFINITY) ? "-inf"
+ .getBytes() : toByteArray(min);
+ byte byteArrayMax[] = (max == Double.POSITIVE_INFINITY) ? "+inf"
+ .getBytes() : toByteArray(max);
- sendCommand(ZREVRANGEBYSCORE, key, byteArrayMax, byteArrayMin,
- LIMIT.raw, toByteArray(offset), toByteArray(count),
- WITHSCORES.raw);
+ sendCommand(ZREVRANGEBYSCORE, key, byteArrayMax, byteArrayMin,
+ LIMIT.raw, toByteArray(offset), toByteArray(count),
+ WITHSCORES.raw);
}
public void zrevrangeByScoreWithScores(final byte[] key, final String max,
- final String min, final int offset, final int count) {
+ final String min, final int offset, final int count) {
- sendCommand(ZREVRANGEBYSCORE, key, max.getBytes(), min.getBytes(),
- LIMIT.raw, toByteArray(offset), toByteArray(count),
- WITHSCORES.raw);
+ sendCommand(ZREVRANGEBYSCORE, key, max.getBytes(), min.getBytes(),
+ LIMIT.raw, toByteArray(offset), toByteArray(count),
+ WITHSCORES.raw);
}
-
+
public void zrangeByScore(final byte[] key, final byte[] min,
final byte[] max, final int offset, int count) {
sendCommand(ZRANGEBYSCORE, key, min, max, LIMIT.raw,
@@ -746,11 +781,11 @@ public class BinaryClient extends Connection {
public void zremrangeByScore(final byte[] key, final byte[] start,
final byte[] end) {
sendCommand(ZREMRANGEBYSCORE, key, start, end);
- }
+ }
public void zremrangeByScore(final byte[] key, final String start,
- final String end) {
- sendCommand(ZREMRANGEBYSCORE, key, start.getBytes(), end.getBytes());
+ final String end) {
+ sendCommand(ZREMRANGEBYSCORE, key, start.getBytes(), end.getBytes());
}
public void zunionstore(final byte[] dstkey, final byte[]... sets) {
@@ -816,7 +851,7 @@ public class BinaryClient extends Connection {
public void info() {
sendCommand(INFO);
}
-
+
public void info(final String section) {
sendCommand(INFO, section);
}
@@ -888,7 +923,7 @@ public class BinaryClient extends Connection {
}
public void setbit(byte[] key, long offset, boolean value) {
- sendCommand(SETBIT, key, toByteArray(offset), toByteArray(value));
+ sendCommand(SETBIT, key, toByteArray(offset), toByteArray(value));
}
public void getbit(byte[] key, long offset) {
@@ -913,6 +948,14 @@ public class BinaryClient extends Connection {
super.disconnect();
}
+ public void resetState() {
+ if (isInMulti())
+ discard();
+
+ if (isInWatch())
+ unwatch();
+ }
+
private void sendEvalCommand(Command command, byte[] script,
byte[] keyCount, byte[][] params) {
@@ -932,7 +975,7 @@ public class BinaryClient extends Connection {
}
public void eval(byte[] script, int keyCount, byte[]... params) {
- eval(script, toByteArray(keyCount), params);
+ eval(script, toByteArray(keyCount), params);
}
public void evalsha(byte[] sha1, byte[] keyCount, byte[]... params) {
@@ -940,7 +983,7 @@ public class BinaryClient extends Connection {
}
public void evalsha(byte[] sha1, int keyCount, byte[]... params) {
- sendEvalCommand(EVALSHA, sha1, toByteArray(keyCount), params);
+ sendEvalCommand(EVALSHA, sha1, toByteArray(keyCount), params);
}
public void scriptFlush() {
@@ -993,111 +1036,160 @@ public class BinaryClient extends Connection {
}
public void bitcount(byte[] key) {
- sendCommand(BITCOUNT, key);
+ sendCommand(BITCOUNT, key);
}
public void bitcount(byte[] key, long start, long end) {
- sendCommand(BITCOUNT, key, toByteArray(start), toByteArray(end));
+ sendCommand(BITCOUNT, key, toByteArray(start), toByteArray(end));
}
public void bitop(BitOP op, byte[] destKey, byte[]... srcKeys) {
- Keyword kw = Keyword.AND;
- int len = srcKeys.length;
- switch (op) {
- case AND:
- kw = Keyword.AND;
- break;
- case OR:
- kw = Keyword.OR;
- break;
- case XOR:
- kw = Keyword.XOR;
- break;
- case NOT:
- kw = Keyword.NOT;
- len = Math.min(1, len);
- break;
- }
+ Keyword kw = Keyword.AND;
+ int len = srcKeys.length;
+ switch (op) {
+ case AND:
+ kw = Keyword.AND;
+ break;
+ case OR:
+ kw = Keyword.OR;
+ break;
+ case XOR:
+ kw = Keyword.XOR;
+ break;
+ case NOT:
+ kw = Keyword.NOT;
+ len = Math.min(1, len);
+ break;
+ }
- byte[][] bargs = new byte[len + 2][];
- bargs[0] = kw.raw;
- bargs[1] = destKey;
- for (int i = 0; i < len; ++i) {
- bargs[i + 2] = srcKeys[i];
- }
+ byte[][] bargs = new byte[len + 2][];
+ bargs[0] = kw.raw;
+ bargs[1] = destKey;
+ for (int i = 0; i < len; ++i) {
+ bargs[i + 2] = srcKeys[i];
+ }
- sendCommand(BITOP, bargs);
+ sendCommand(BITOP, bargs);
}
public void sentinel(final byte[]... args) {
- sendCommand(SENTINEL, args);
+ sendCommand(SENTINEL, args);
}
-
+
public void dump(final byte[] key) {
- sendCommand(DUMP, key);
+ sendCommand(DUMP, key);
}
-
- public void restore(final byte[] key, final int ttl, final byte[] serializedValue) {
- sendCommand(RESTORE, key, toByteArray(ttl), serializedValue);
+
+ public void restore(final byte[] key, final int ttl,
+ final byte[] serializedValue) {
+ sendCommand(RESTORE, key, toByteArray(ttl), serializedValue);
}
-
+
public void pexpire(final byte[] key, final int milliseconds) {
- sendCommand(PEXPIRE, key, toByteArray(milliseconds));
+ sendCommand(PEXPIRE, key, toByteArray(milliseconds));
}
-
+
public void pexpireAt(final byte[] key, final long millisecondsTimestamp) {
- sendCommand(PEXPIREAT, key, toByteArray(millisecondsTimestamp));
+ sendCommand(PEXPIREAT, key, toByteArray(millisecondsTimestamp));
}
-
+
public void pttl(final byte[] key) {
- sendCommand(PTTL, key);
+ sendCommand(PTTL, key);
}
-
+
public void incrByFloat(final byte[] key, final double increment) {
- sendCommand(INCRBYFLOAT, key, toByteArray(increment));
+ sendCommand(INCRBYFLOAT, key, toByteArray(increment));
}
-
- public void psetex(final byte[] key, final int milliseconds, final byte[] value) {
- sendCommand(PSETEX, key, toByteArray(milliseconds), value);
+
+ public void psetex(final byte[] key, final int milliseconds,
+ final byte[] value) {
+ sendCommand(PSETEX, key, toByteArray(milliseconds), value);
}
-
+
public void set(final byte[] key, final byte[] value, final byte[] nxxx) {
- sendCommand(Command.SET, key, value, nxxx);
+ sendCommand(Command.SET, key, value, nxxx);
}
-
- public void set(final byte[] key, final byte[] value, final byte[] nxxx, final byte[] expx, final int time) {
- sendCommand(Command.SET, key, value, nxxx, expx, toByteArray(time));
+
+ public void set(final byte[] key, final byte[] value, final byte[] nxxx,
+ final byte[] expx, final int time) {
+ sendCommand(Command.SET, key, value, nxxx, expx, toByteArray(time));
}
-
+
public void srandmember(final byte[] key, final int count) {
- sendCommand(SRANDMEMBER, key, toByteArray(count));
+ sendCommand(SRANDMEMBER, key, toByteArray(count));
}
-
+
public void clientKill(final byte[] client) {
- sendCommand(CLIENT, Keyword.KILL.raw, client);
+ sendCommand(CLIENT, Keyword.KILL.raw, client);
}
-
+
public void clientGetname() {
- sendCommand(CLIENT, Keyword.GETNAME.raw);
+ sendCommand(CLIENT, Keyword.GETNAME.raw);
}
-
+
public void clientList() {
- sendCommand(CLIENT, Keyword.LIST.raw);
+ sendCommand(CLIENT, Keyword.LIST.raw);
}
-
+
public void clientSetname(final byte[] name) {
- sendCommand(CLIENT, Keyword.SETNAME.raw, name);
+ sendCommand(CLIENT, Keyword.SETNAME.raw, name);
}
-
+
public void time() {
- sendCommand(TIME);
+ sendCommand(TIME);
}
-
- public void migrate(final byte[] host, final int port, final byte[] key, final int destinationDb, final int timeout) {
- sendCommand(MIGRATE, host, toByteArray(port), key, toByteArray(destinationDb), toByteArray(timeout));
+
+ public void migrate(final byte[] host, final int port, final byte[] key,
+ final int destinationDb, final int timeout) {
+ sendCommand(MIGRATE, host, toByteArray(port), key,
+ toByteArray(destinationDb), toByteArray(timeout));
}
-
- public void hincrByFloat(final byte[] key, final byte[] field, double increment) {
- sendCommand(HINCRBYFLOAT, key, field, toByteArray(increment));
+
+ public void hincrByFloat(final byte[] key, final byte[] field,
+ double increment) {
+ sendCommand(HINCRBYFLOAT, key, field, toByteArray(increment));
+ }
+
+ public void scan(int cursor, final ScanParams params) {
+ final List args = new ArrayList();
+ args.add(toByteArray(cursor));
+ args.addAll(params.getParams());
+ sendCommand(SCAN, args.toArray(new byte[args.size()][]));
+ }
+
+ public void hscan(final byte[] key, int cursor, final ScanParams params) {
+ final List args = new ArrayList();
+ args.add(key);
+ args.add(toByteArray(cursor));
+ args.addAll(params.getParams());
+ sendCommand(HSCAN, args.toArray(new byte[args.size()][]));
+ }
+
+ public void sscan(final byte[] key, int cursor, final ScanParams params) {
+ final List args = new ArrayList();
+ args.add(key);
+ args.add(toByteArray(cursor));
+ args.addAll(params.getParams());
+ sendCommand(SSCAN, args.toArray(new byte[args.size()][]));
+ }
+
+ public void zscan(final byte[] key, int cursor, final ScanParams params) {
+ final List args = new ArrayList();
+ args.add(key);
+ args.add(toByteArray(cursor));
+ args.addAll(params.getParams());
+ sendCommand(ZSCAN, args.toArray(new byte[args.size()][]));
+ }
+
+ public void waitReplicas(int replicas, long timeout) {
+ sendCommand(WAIT, toByteArray(replicas), toByteArray(timeout));
+ }
+
+ public void cluster(final byte[]... args) {
+ sendCommand(CLUSTER, args);
+ }
+
+ public void asking() {
+ sendCommand(Command.ASKING);
}
}
diff --git a/src/main/java/redis/clients/jedis/BinaryJedis.java b/src/main/java/redis/clients/jedis/BinaryJedis.java
index 385b1c0..991d046 100644
--- a/src/main/java/redis/clients/jedis/BinaryJedis.java
+++ b/src/main/java/redis/clients/jedis/BinaryJedis.java
@@ -1,17 +1,25 @@
package redis.clients.jedis;
+import static redis.clients.jedis.Protocol.toByteArray;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
import redis.clients.jedis.BinaryClient.LIST_POSITION;
import redis.clients.jedis.exceptions.JedisDataException;
import redis.clients.jedis.exceptions.JedisException;
import redis.clients.util.JedisByteHashMap;
import redis.clients.util.SafeEncoder;
-import java.net.URI;
-import java.util.*;
-
-import static redis.clients.jedis.Protocol.toByteArray;
-
-public class BinaryJedis implements BasicCommands, BinaryJedisCommands, MultiKeyBinaryCommands, AdvancedBinaryJedisCommands, BinaryScriptingCommands {
+public class BinaryJedis implements BasicCommands, BinaryJedisCommands,
+ MultiKeyBinaryCommands, AdvancedBinaryJedisCommands,
+ BinaryScriptingCommands {
protected Client client = null;
public BinaryJedis(final String host) {
@@ -75,18 +83,23 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands, MultiKey
/**
* Set the string value as value of the key. The string can't be longer than
* 1073741824 bytes (1 GB).
+ *
* @param key
* @param value
- * @param nxxx NX|XX, NX -- Only set the key if it does not already exist.
- * XX -- Only set the key if it already exist.
- * @param expx EX|PX, expire time units: EX = seconds; PX = milliseconds
- * @param time expire time in the units of {@param #expx}
+ * @param nxxx
+ * NX|XX, NX -- Only set the key if it does not already exist. XX
+ * -- Only set the key if it already exist.
+ * @param expx
+ * EX|PX, expire time units: EX = seconds; PX = milliseconds
+ * @param time
+ * expire time in the units of {@param #expx}
* @return Status code reply
*/
- public String set(final byte[] key, final byte[] value, final byte[] nxxx, final byte[] expx, final long time) {
- checkIsInMulti();
- client.set(key, value, nxxx, expx, time);
- return client.getStatusCodeReply();
+ public String set(final byte[] key, final byte[] value, final byte[] nxxx,
+ final byte[] expx, final long time) {
+ checkIsInMulti();
+ client.set(key, value, nxxx, expx, time);
+ return client.getStatusCodeReply();
}
/**
@@ -147,9 +160,9 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands, MultiKey
}
public Long del(final byte[] key) {
- checkIsInMulti();
- client.del(key);
- return client.getIntegerReply();
+ checkIsInMulti();
+ client.del(key);
+ return client.getIntegerReply();
}
/**
@@ -1006,7 +1019,8 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands, MultiKey
* @return Multi bulk reply, specifically a list of elements in the
* specified range.
*/
- public List lrange(final byte[] key, final long start, final long end) {
+ public List lrange(final byte[] key, final long start,
+ final long end) {
checkIsInMulti();
client.lrange(key, start, end);
return client.getBinaryMultiBulkReply();
@@ -1468,11 +1482,11 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands, MultiKey
client.srandmember(key);
return client.getBinaryBulkReply();
}
-
+
public List srandmember(final byte[] key, final int count) {
- checkIsInMulti();
- client.srandmember(key, count);
- return client.getBinaryMultiBulkReply();
+ checkIsInMulti();
+ client.srandmember(key, count);
+ return client.getBinaryMultiBulkReply();
}
/**
@@ -1502,7 +1516,7 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands, MultiKey
return client.getIntegerReply();
}
- public Long zadd(final byte[] key, final Map scoreMembers) {
+ public Long zadd(final byte[] key, final Map scoreMembers) {
checkIsInMulti();
client.zaddBinary(key, scoreMembers);
return client.getIntegerReply();
@@ -1685,13 +1699,9 @@ public class BinaryJedis implements BasicCommands, BinaryJedisCommands, MultiKey
public List