diff --git a/.gitignore b/.gitignore
index e917613..982e6b6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,11 @@
.classpath
+*.iml
+*.ipr
+*.iws
.project
.settings/
.gradle/
target/
build/
+bin/
+tags
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..00f29bf
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,42 @@
+define REDIS1_CONF
+daemonize yes
+port 6379
+requirepass foobared
+pidfile /tmp/redis1.pid
+endef
+
+define REDIS2_CONF
+daemonize yes
+port 6380
+requirepass foobared
+pidfile /tmp/redis2.pid
+endef
+
+
+define REDIS_SENTINEL1
+port 26379
+daemonize yes
+sentinel monitor mymaster 127.0.0.1 6379 2
+sentinel auth-pass mymaster foobared
+sentinel down-after-milliseconds mymaster 5000
+sentinel failover-timeout mymaster 900000
+sentinel can-failover mymaster yes
+sentinel parallel-syncs mymaster 1
+pidfile /tmp/sentinel1.pid
+endef
+
+export REDIS1_CONF
+export REDIS2_CONF
+export REDIS_SENTINEL1
+test:
+ echo "$$REDIS1_CONF" | redis-server -
+ echo "$$REDIS2_CONF" | redis-server -
+ echo "$$REDIS_SENTINEL1" | redis-sentinel -
+
+ mvn clean compile test
+
+ kill `cat /tmp/redis1.pid`
+ kill `cat /tmp/redis2.pid`
+ kill `cat /tmp/sentinel1.pid`
+
+.PHONY: test
diff --git a/README.md b/README.md
index 558111b..ae89c9f 100644
--- a/README.md
+++ b/README.md
@@ -48,20 +48,23 @@ You can download the latest build at:
Or use it as a maven dependency:
-
- redis.clients
- jedis
- 2.0.0
- jar
- compile
-
-
+```xml
+
+ redis.clients
+ jedis
+ 2.0.0
+ jar
+ compile
+
+```
To use it just:
- Jedis jedis = new Jedis("localhost");
- jedis.set("foo", "bar");
- String value = jedis.get("foo");
+```java
+Jedis jedis = new Jedis("localhost");
+jedis.set("foo", "bar");
+String value = jedis.get("foo");
+```
For more usage examples check the tests.
@@ -77,7 +80,7 @@ To run the tests:
- Use the latest redis master branch.
-- Run 2 instances of redis [using conf files in conf folder](https://github.com/xetorthio/jedis/wiki). For the tests we use 2 redis servers, one on default port (6379) and the other one on (6380). Both have authentication enabled with default password (foobared). This way we can test both sharding and auth command.
+- Run ```make test```. This will run 2 instances of redis. We use 2 redis servers, one on default port (6379) and the other one on (6380). Both have authentication enabled with default password (foobared). This way we can test both sharding and auth command.
Thanks for helping!
diff --git a/build.gradle b/build.gradle
index a956f7e..e9076f3 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,5 +1,6 @@
apply plugin: 'java'
apply plugin: 'maven'
+apply plugin: 'eclipse'
group = 'com.googlecode.jedis'
archiveBaseName = 'jedis'
@@ -25,3 +26,8 @@ uploadArchives {
}
}
*/
+
+task createWrapper(type: Wrapper) {
+ gradleVersion = '1.0-milestone-6'
+}
+
diff --git a/conf/redis.conf b/conf/redis.conf
deleted file mode 100644
index eceedb6..0000000
--- a/conf/redis.conf
+++ /dev/null
@@ -1,332 +0,0 @@
-# Redis configuration file example
-
-# Note on units: when memory size is needed, it is possible to specifiy
-# it in the usual form of 1k 5GB 4M and so forth:
-#
-# 1k => 1000 bytes
-# 1kb => 1024 bytes
-# 1m => 1000000 bytes
-# 1mb => 1024*1024 bytes
-# 1g => 1000000000 bytes
-# 1gb => 1024*1024*1024 bytes
-#
-# units are case insensitive so 1GB 1Gb 1gB are all the same.
-
-# By default Redis does not run as a daemon. Use 'yes' if you need it.
-# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
-daemonize no
-
-# When running daemonized, Redis writes a pid file in /var/run/redis.pid by
-# default. You can specify a custom pid file location here.
-pidfile /var/run/redis.pid
-
-# Accept connections on the specified port, default is 6379
-port 6379
-
-# If you want you can bind a single interface, if the bind option is not
-# specified all the interfaces will listen for incoming connections.
-#
-# bind 127.0.0.1
-
-# Close the connection after a client is idle for N seconds (0 to disable)
-timeout 300
-
-# Set server verbosity to 'debug'
-# it can be one of:
-# debug (a lot of information, useful for development/testing)
-# verbose (many rarely useful info, but not a mess like the debug level)
-# notice (moderately verbose, what you want in production probably)
-# warning (only very important / critical messages are logged)
-loglevel verbose
-
-# Specify the log file name. Also 'stdout' can be used to force
-# Redis to log on the standard output. Note that if you use standard
-# output for logging but daemonize, logs will be sent to /dev/null
-logfile stdout
-
-# Set the number of databases. The default database is DB 0, you can select
-# a different one on a per-connection basis using SELECT where
-# dbid is a number between 0 and 'databases'-1
-databases 16
-
-################################ SNAPSHOTTING #################################
-#
-# Save the DB on disk:
-#
-# save
-#
-# Will save the DB if both the given number of seconds and the given
-# number of write operations against the DB occurred.
-#
-# In the example below the behaviour will be to save:
-# after 900 sec (15 min) if at least 1 key changed
-# after 300 sec (5 min) if at least 10 keys changed
-# after 60 sec if at least 10000 keys changed
-#
-# Note: you can disable saving at all commenting all the "save" lines.
-
-save 900 1
-save 300 10
-save 60 10000
-
-# Compress string objects using LZF when dump .rdb databases?
-# For default that's set to 'yes' as it's almost always a win.
-# If you want to save some CPU in the saving child set it to 'no' but
-# the dataset will likely be bigger if you have compressible values or keys.
-rdbcompression yes
-
-# The filename where to dump the DB
-dbfilename dump.rdb
-
-# The working directory.
-#
-# The DB will be written inside this directory, with the filename specified
-# above using the 'dbfilename' configuration directive.
-#
-# Also the Append Only File will be created inside this directory.
-#
-# Note that you must specify a directory here, not a file name.
-dir ./
-
-################################# REPLICATION #################################
-
-# Master-Slave replication. Use slaveof to make a Redis instance a copy of
-# another Redis server. Note that the configuration is local to the slave
-# so for example it is possible to configure the slave to save the DB with a
-# different interval, or to listen to another port, and so on.
-#
-# slaveof
-
-# If the master is password protected (using the "requirepass" configuration
-# directive below) it is possible to tell the slave to authenticate before
-# starting the replication synchronization process, otherwise the master will
-# refuse the slave request.
-#
-# masterauth
-
-################################## SECURITY ###################################
-
-# Require clients to issue AUTH before processing any other
-# commands. This might be useful in environments in which you do not trust
-# others with access to the host running redis-server.
-#
-# This should stay commented out for backward compatibility and because most
-# people do not need auth (e.g. they run their own servers).
-#
-# Warning: since Redis is pretty fast an outside user can try up to
-# 150k passwords per second against a good box. This means that you should
-# use a very strong password otherwise it will be very easy to break.
-#
-requirepass foobared
-
-################################### LIMITS ####################################
-
-# Set the max number of connected clients at the same time. By default there
-# is no limit, and it's up to the number of file descriptors the Redis process
-# is able to open. The special value '0' means no limits.
-# Once the limit is reached Redis will close all the new connections sending
-# an error 'max number of clients reached'.
-#
-# maxclients 128
-
-# Don't use more memory than the specified amount of bytes.
-# When the memory limit is reached Redis will try to remove keys with an
-# EXPIRE set. It will try to start freeing keys that are going to expire
-# in little time and preserve keys with a longer time to live.
-# Redis will also try to remove objects from free lists if possible.
-#
-# If all this fails, Redis will start to reply with errors to commands
-# that will use more memory, like SET, LPUSH, and so on, and will continue
-# to reply to most read-only commands like GET.
-#
-# WARNING: maxmemory can be a good idea mainly if you want to use Redis as a
-# 'state' server or cache, not as a real DB. When Redis is used as a real
-# database the memory usage will grow over the weeks, it will be obvious if
-# it is going to use too much memory in the long run, and you'll have the time
-# to upgrade. With maxmemory after the limit is reached you'll start to get
-# errors for write operations, and this may even lead to DB inconsistency.
-#
-# maxmemory
-
-############################## APPEND ONLY MODE ###############################
-
-# By default Redis asynchronously dumps the dataset on disk. If you can live
-# with the idea that the latest records will be lost if something like a crash
-# happens this is the preferred way to run Redis. If instead you care a lot
-# about your data and don't want to that a single record can get lost you should
-# enable the append only mode: when this mode is enabled Redis will append
-# every write operation received in the file appendonly.aof. This file will
-# be read on startup in order to rebuild the full dataset in memory.
-#
-# Note that you can have both the async dumps and the append only file if you
-# like (you have to comment the "save" statements above to disable the dumps).
-# Still if append only mode is enabled Redis will load the data from the
-# log file at startup ignoring the dump.rdb file.
-#
-# IMPORTANT: Check the BGREWRITEAOF to check how to rewrite the append
-# log file in background when it gets too big.
-
-appendonly no
-
-# The name of the append only file (default: "appendonly.aof")
-# appendfilename appendonly.aof
-
-# The fsync() call tells the Operating System to actually write data on disk
-# instead to wait for more data in the output buffer. Some OS will really flush
-# data on disk, some other OS will just try to do it ASAP.
-#
-# Redis supports three different modes:
-#
-# no: don't fsync, just let the OS flush the data when it wants. Faster.
-# always: fsync after every write to the append only log . Slow, Safest.
-# everysec: fsync only if one second passed since the last fsync. Compromise.
-#
-# The default is "everysec" that's usually the right compromise between
-# speed and data safety. It's up to you to understand if you can relax this to
-# "no" that will will let the operating system flush the output buffer when
-# it wants, for better performances (but if you can live with the idea of
-# some data loss consider the default persistence mode that's snapshotting),
-# or on the contrary, use "always" that's very slow but a bit safer than
-# everysec.
-#
-# If unsure, use "everysec".
-
-# appendfsync always
-appendfsync everysec
-# appendfsync no
-
-# When the AOF fsync policy is set to always or everysec, and a background
-# saving process (a background save or AOF log background rewriting) is
-# performing a lot of I/O against the disk, in some Linux configurations
-# Redis may block too long on the fsync() call. Note that there is no fix for
-# this currently, as even performing fsync in a different thread will block
-# our synchronous write(2) call.
-#
-# In order to mitigate this problem it's possible to use the following option
-# that will prevent fsync() from being called in the main process while a
-# BGSAVE or BGREWRITEAOF is in progress.
-#
-# This means that while another child is saving the durability of Redis is
-# the same as "appendfsync none", that in pratical terms means that it is
-# possible to lost up to 30 seconds of log in the worst scenario (with the
-# default Linux settings).
-#
-# If you have latency problems turn this to "yes". Otherwise leave it as
-# "no" that is the safest pick from the point of view of durability.
-no-appendfsync-on-rewrite no
-
-################################ VIRTUAL MEMORY ###############################
-
-# Virtual Memory allows Redis to work with datasets bigger than the actual
-# amount of RAM needed to hold the whole dataset in memory.
-# In order to do so very used keys are taken in memory while the other keys
-# are swapped into a swap file, similarly to what operating systems do
-# with memory pages.
-#
-# To enable VM just set 'vm-enabled' to yes, and set the following three
-# VM parameters accordingly to your needs.
-
-vm-enabled no
-# vm-enabled yes
-
-# This is the path of the Redis swap file. As you can guess, swap files
-# can't be shared by different Redis instances, so make sure to use a swap
-# file for every redis process you are running. Redis will complain if the
-# swap file is already in use.
-#
-# The best kind of storage for the Redis swap file (that's accessed at random)
-# is a Solid State Disk (SSD).
-#
-# *** WARNING *** if you are using a shared hosting the default of putting
-# the swap file under /tmp is not secure. Create a dir with access granted
-# only to Redis user and configure Redis to create the swap file there.
-vm-swap-file /tmp/redis.swap
-
-# vm-max-memory configures the VM to use at max the specified amount of
-# RAM. Everything that deos not fit will be swapped on disk *if* possible, that
-# is, if there is still enough contiguous space in the swap file.
-#
-# With vm-max-memory 0 the system will swap everything it can. Not a good
-# default, just specify the max amount of RAM you can in bytes, but it's
-# better to leave some margin. For instance specify an amount of RAM
-# that's more or less between 60 and 80% of your free RAM.
-vm-max-memory 0
-
-# Redis swap files is split into pages. An object can be saved using multiple
-# contiguous pages, but pages can't be shared between different objects.
-# So if your page is too big, small objects swapped out on disk will waste
-# a lot of space. If you page is too small, there is less space in the swap
-# file (assuming you configured the same number of total swap file pages).
-#
-# If you use a lot of small objects, use a page size of 64 or 32 bytes.
-# If you use a lot of big objects, use a bigger page size.
-# If unsure, use the default :)
-vm-page-size 32
-
-# Number of total memory pages in the swap file.
-# Given that the page table (a bitmap of free/used pages) is taken in memory,
-# every 8 pages on disk will consume 1 byte of RAM.
-#
-# The total swap size is vm-page-size * vm-pages
-#
-# With the default of 32-bytes memory pages and 134217728 pages Redis will
-# use a 4 GB swap file, that will use 16 MB of RAM for the page table.
-#
-# It's better to use the smallest acceptable value for your application,
-# but the default is large in order to work in most conditions.
-vm-pages 134217728
-
-# Max number of VM I/O threads running at the same time.
-# This threads are used to read/write data from/to swap file, since they
-# also encode and decode objects from disk to memory or the reverse, a bigger
-# number of threads can help with big objects even if they can't help with
-# I/O itself as the physical device may not be able to couple with many
-# reads/writes operations at the same time.
-#
-# The special value of 0 turn off threaded I/O and enables the blocking
-# Virtual Memory implementation.
-vm-max-threads 4
-
-############################### ADVANCED CONFIG ###############################
-
-# Glue small output buffers together in order to send small replies in a
-# single TCP packet. Uses a bit more CPU but most of the times it is a win
-# in terms of number of queries per second. Use 'yes' if unsure.
-glueoutputbuf yes
-
-# Hashes are encoded in a special way (much more memory efficient) when they
-# have at max a given numer of elements, and the biggest element does not
-# exceed a given threshold. You can configure this limits with the following
-# configuration directives.
-hash-max-zipmap-entries 64
-hash-max-zipmap-value 512
-
-# Active rehashing uses 1 millisecond every 100 milliseconds of CPU time in
-# order to help rehashing the main Redis hash table (the one mapping top-level
-# keys to values). The hash table implementation redis uses (see dict.c)
-# performs a lazy rehashing: the more operation you run into an hash table
-# that is rhashing, the more rehashing "steps" are performed, so if the
-# server is idle the rehashing is never complete and some more memory is used
-# by the hash table.
-#
-# The default is to use this millisecond 10 times every second in order to
-# active rehashing the main dictionaries, freeing memory when possible.
-#
-# If unsure:
-# use "activerehashing no" if you have hard latency requirements and it is
-# not a good thing in your environment that Redis can reply form time to time
-# to queries with 2 milliseconds delay.
-#
-# use "activerehashing yes" if you don't have such hard requirements but
-# want to free memory asap when possible.
-activerehashing yes
-
-################################## INCLUDES ###################################
-
-# Include one or more other config files here. This is useful if you
-# have a standard template that goes to all redis server but also need
-# to customize a few per-server settings. Include files can include
-# other files, so use this wisely.
-#
-# include /path/to/local.conf
-# include /path/to/other.conf
diff --git a/conf/redis2.conf b/conf/redis2.conf
deleted file mode 100644
index c59e989..0000000
--- a/conf/redis2.conf
+++ /dev/null
@@ -1,332 +0,0 @@
-# Redis configuration file example
-
-# Note on units: when memory size is needed, it is possible to specifiy
-# it in the usual form of 1k 5GB 4M and so forth:
-#
-# 1k => 1000 bytes
-# 1kb => 1024 bytes
-# 1m => 1000000 bytes
-# 1mb => 1024*1024 bytes
-# 1g => 1000000000 bytes
-# 1gb => 1024*1024*1024 bytes
-#
-# units are case insensitive so 1GB 1Gb 1gB are all the same.
-
-# By default Redis does not run as a daemon. Use 'yes' if you need it.
-# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
-daemonize no
-
-# When running daemonized, Redis writes a pid file in /var/run/redis.pid by
-# default. You can specify a custom pid file location here.
-pidfile /var/run/redis.pid
-
-# Accept connections on the specified port, default is 6379
-port 6380
-
-# If you want you can bind a single interface, if the bind option is not
-# specified all the interfaces will listen for incoming connections.
-#
-# bind 127.0.0.1
-
-# Close the connection after a client is idle for N seconds (0 to disable)
-timeout 300
-
-# Set server verbosity to 'debug'
-# it can be one of:
-# debug (a lot of information, useful for development/testing)
-# verbose (many rarely useful info, but not a mess like the debug level)
-# notice (moderately verbose, what you want in production probably)
-# warning (only very important / critical messages are logged)
-loglevel verbose
-
-# Specify the log file name. Also 'stdout' can be used to force
-# Redis to log on the standard output. Note that if you use standard
-# output for logging but daemonize, logs will be sent to /dev/null
-logfile stdout
-
-# Set the number of databases. The default database is DB 0, you can select
-# a different one on a per-connection basis using SELECT where
-# dbid is a number between 0 and 'databases'-1
-databases 16
-
-################################ SNAPSHOTTING #################################
-#
-# Save the DB on disk:
-#
-# save
-#
-# Will save the DB if both the given number of seconds and the given
-# number of write operations against the DB occurred.
-#
-# In the example below the behaviour will be to save:
-# after 900 sec (15 min) if at least 1 key changed
-# after 300 sec (5 min) if at least 10 keys changed
-# after 60 sec if at least 10000 keys changed
-#
-# Note: you can disable saving at all commenting all the "save" lines.
-
-save 900 1
-save 300 10
-save 60 10000
-
-# Compress string objects using LZF when dump .rdb databases?
-# For default that's set to 'yes' as it's almost always a win.
-# If you want to save some CPU in the saving child set it to 'no' but
-# the dataset will likely be bigger if you have compressible values or keys.
-rdbcompression yes
-
-# The filename where to dump the DB
-dbfilename dump.rdb
-
-# The working directory.
-#
-# The DB will be written inside this directory, with the filename specified
-# above using the 'dbfilename' configuration directive.
-#
-# Also the Append Only File will be created inside this directory.
-#
-# Note that you must specify a directory here, not a file name.
-dir ./
-
-################################# REPLICATION #################################
-
-# Master-Slave replication. Use slaveof to make a Redis instance a copy of
-# another Redis server. Note that the configuration is local to the slave
-# so for example it is possible to configure the slave to save the DB with a
-# different interval, or to listen to another port, and so on.
-#
-# slaveof
-
-# If the master is password protected (using the "requirepass" configuration
-# directive below) it is possible to tell the slave to authenticate before
-# starting the replication synchronization process, otherwise the master will
-# refuse the slave request.
-#
-# masterauth
-
-################################## SECURITY ###################################
-
-# Require clients to issue AUTH before processing any other
-# commands. This might be useful in environments in which you do not trust
-# others with access to the host running redis-server.
-#
-# This should stay commented out for backward compatibility and because most
-# people do not need auth (e.g. they run their own servers).
-#
-# Warning: since Redis is pretty fast an outside user can try up to
-# 150k passwords per second against a good box. This means that you should
-# use a very strong password otherwise it will be very easy to break.
-#
-requirepass foobared
-
-################################### LIMITS ####################################
-
-# Set the max number of connected clients at the same time. By default there
-# is no limit, and it's up to the number of file descriptors the Redis process
-# is able to open. The special value '0' means no limits.
-# Once the limit is reached Redis will close all the new connections sending
-# an error 'max number of clients reached'.
-#
-# maxclients 128
-
-# Don't use more memory than the specified amount of bytes.
-# When the memory limit is reached Redis will try to remove keys with an
-# EXPIRE set. It will try to start freeing keys that are going to expire
-# in little time and preserve keys with a longer time to live.
-# Redis will also try to remove objects from free lists if possible.
-#
-# If all this fails, Redis will start to reply with errors to commands
-# that will use more memory, like SET, LPUSH, and so on, and will continue
-# to reply to most read-only commands like GET.
-#
-# WARNING: maxmemory can be a good idea mainly if you want to use Redis as a
-# 'state' server or cache, not as a real DB. When Redis is used as a real
-# database the memory usage will grow over the weeks, it will be obvious if
-# it is going to use too much memory in the long run, and you'll have the time
-# to upgrade. With maxmemory after the limit is reached you'll start to get
-# errors for write operations, and this may even lead to DB inconsistency.
-#
-# maxmemory
-
-############################## APPEND ONLY MODE ###############################
-
-# By default Redis asynchronously dumps the dataset on disk. If you can live
-# with the idea that the latest records will be lost if something like a crash
-# happens this is the preferred way to run Redis. If instead you care a lot
-# about your data and don't want to that a single record can get lost you should
-# enable the append only mode: when this mode is enabled Redis will append
-# every write operation received in the file appendonly.aof. This file will
-# be read on startup in order to rebuild the full dataset in memory.
-#
-# Note that you can have both the async dumps and the append only file if you
-# like (you have to comment the "save" statements above to disable the dumps).
-# Still if append only mode is enabled Redis will load the data from the
-# log file at startup ignoring the dump.rdb file.
-#
-# IMPORTANT: Check the BGREWRITEAOF to check how to rewrite the append
-# log file in background when it gets too big.
-
-appendonly no
-
-# The name of the append only file (default: "appendonly.aof")
-# appendfilename appendonly.aof
-
-# The fsync() call tells the Operating System to actually write data on disk
-# instead to wait for more data in the output buffer. Some OS will really flush
-# data on disk, some other OS will just try to do it ASAP.
-#
-# Redis supports three different modes:
-#
-# no: don't fsync, just let the OS flush the data when it wants. Faster.
-# always: fsync after every write to the append only log . Slow, Safest.
-# everysec: fsync only if one second passed since the last fsync. Compromise.
-#
-# The default is "everysec" that's usually the right compromise between
-# speed and data safety. It's up to you to understand if you can relax this to
-# "no" that will will let the operating system flush the output buffer when
-# it wants, for better performances (but if you can live with the idea of
-# some data loss consider the default persistence mode that's snapshotting),
-# or on the contrary, use "always" that's very slow but a bit safer than
-# everysec.
-#
-# If unsure, use "everysec".
-
-# appendfsync always
-appendfsync everysec
-# appendfsync no
-
-# When the AOF fsync policy is set to always or everysec, and a background
-# saving process (a background save or AOF log background rewriting) is
-# performing a lot of I/O against the disk, in some Linux configurations
-# Redis may block too long on the fsync() call. Note that there is no fix for
-# this currently, as even performing fsync in a different thread will block
-# our synchronous write(2) call.
-#
-# In order to mitigate this problem it's possible to use the following option
-# that will prevent fsync() from being called in the main process while a
-# BGSAVE or BGREWRITEAOF is in progress.
-#
-# This means that while another child is saving the durability of Redis is
-# the same as "appendfsync none", that in pratical terms means that it is
-# possible to lost up to 30 seconds of log in the worst scenario (with the
-# default Linux settings).
-#
-# If you have latency problems turn this to "yes". Otherwise leave it as
-# "no" that is the safest pick from the point of view of durability.
-no-appendfsync-on-rewrite no
-
-################################ VIRTUAL MEMORY ###############################
-
-# Virtual Memory allows Redis to work with datasets bigger than the actual
-# amount of RAM needed to hold the whole dataset in memory.
-# In order to do so very used keys are taken in memory while the other keys
-# are swapped into a swap file, similarly to what operating systems do
-# with memory pages.
-#
-# To enable VM just set 'vm-enabled' to yes, and set the following three
-# VM parameters accordingly to your needs.
-
-vm-enabled no
-# vm-enabled yes
-
-# This is the path of the Redis swap file. As you can guess, swap files
-# can't be shared by different Redis instances, so make sure to use a swap
-# file for every redis process you are running. Redis will complain if the
-# swap file is already in use.
-#
-# The best kind of storage for the Redis swap file (that's accessed at random)
-# is a Solid State Disk (SSD).
-#
-# *** WARNING *** if you are using a shared hosting the default of putting
-# the swap file under /tmp is not secure. Create a dir with access granted
-# only to Redis user and configure Redis to create the swap file there.
-vm-swap-file /tmp/redis.swap
-
-# vm-max-memory configures the VM to use at max the specified amount of
-# RAM. Everything that deos not fit will be swapped on disk *if* possible, that
-# is, if there is still enough contiguous space in the swap file.
-#
-# With vm-max-memory 0 the system will swap everything it can. Not a good
-# default, just specify the max amount of RAM you can in bytes, but it's
-# better to leave some margin. For instance specify an amount of RAM
-# that's more or less between 60 and 80% of your free RAM.
-vm-max-memory 0
-
-# Redis swap files is split into pages. An object can be saved using multiple
-# contiguous pages, but pages can't be shared between different objects.
-# So if your page is too big, small objects swapped out on disk will waste
-# a lot of space. If you page is too small, there is less space in the swap
-# file (assuming you configured the same number of total swap file pages).
-#
-# If you use a lot of small objects, use a page size of 64 or 32 bytes.
-# If you use a lot of big objects, use a bigger page size.
-# If unsure, use the default :)
-vm-page-size 32
-
-# Number of total memory pages in the swap file.
-# Given that the page table (a bitmap of free/used pages) is taken in memory,
-# every 8 pages on disk will consume 1 byte of RAM.
-#
-# The total swap size is vm-page-size * vm-pages
-#
-# With the default of 32-bytes memory pages and 134217728 pages Redis will
-# use a 4 GB swap file, that will use 16 MB of RAM for the page table.
-#
-# It's better to use the smallest acceptable value for your application,
-# but the default is large in order to work in most conditions.
-vm-pages 134217728
-
-# Max number of VM I/O threads running at the same time.
-# This threads are used to read/write data from/to swap file, since they
-# also encode and decode objects from disk to memory or the reverse, a bigger
-# number of threads can help with big objects even if they can't help with
-# I/O itself as the physical device may not be able to couple with many
-# reads/writes operations at the same time.
-#
-# The special value of 0 turn off threaded I/O and enables the blocking
-# Virtual Memory implementation.
-vm-max-threads 4
-
-############################### ADVANCED CONFIG ###############################
-
-# Glue small output buffers together in order to send small replies in a
-# single TCP packet. Uses a bit more CPU but most of the times it is a win
-# in terms of number of queries per second. Use 'yes' if unsure.
-glueoutputbuf yes
-
-# Hashes are encoded in a special way (much more memory efficient) when they
-# have at max a given numer of elements, and the biggest element does not
-# exceed a given threshold. You can configure this limits with the following
-# configuration directives.
-hash-max-zipmap-entries 64
-hash-max-zipmap-value 512
-
-# Active rehashing uses 1 millisecond every 100 milliseconds of CPU time in
-# order to help rehashing the main Redis hash table (the one mapping top-level
-# keys to values). The hash table implementation redis uses (see dict.c)
-# performs a lazy rehashing: the more operation you run into an hash table
-# that is rhashing, the more rehashing "steps" are performed, so if the
-# server is idle the rehashing is never complete and some more memory is used
-# by the hash table.
-#
-# The default is to use this millisecond 10 times every second in order to
-# active rehashing the main dictionaries, freeing memory when possible.
-#
-# If unsure:
-# use "activerehashing no" if you have hard latency requirements and it is
-# not a good thing in your environment that Redis can reply form time to time
-# to queries with 2 milliseconds delay.
-#
-# use "activerehashing yes" if you don't have such hard requirements but
-# want to free memory asap when possible.
-activerehashing yes
-
-################################## INCLUDES ###################################
-
-# Include one or more other config files here. This is useful if you
-# have a standard template that goes to all redis server but also need
-# to customize a few per-server settings. Include files can include
-# other files, so use this wisely.
-#
-# include /path/to/local.conf
-# include /path/to/other.conf
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index b7853ef..45bfb5c 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 f96e2df..b3e777e 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,9 +1,6 @@
-#Mon Jan 18 09:35:53 CET 2010
+#Fri Dec 23 12:54:50 CST 2011
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
-distributionVersion=0.9-preview-3
zipStorePath=wrapper/dists
-urlRoot=http\://dist.codehaus.org/gradle/
-distributionName=gradle
-distributionClassifier=bin
+distributionUrl=http\://repo.gradle.org/gradle/distributions/gradle-1.0-milestone-6-bin.zip
diff --git a/gradlew b/gradlew
index 820f5cf..d8809f1 100755
--- a/gradlew
+++ b/gradlew
@@ -7,21 +7,25 @@
##############################################################################
# Uncomment those lines to set JVM options. GRADLE_OPTS and JAVA_OPTS can be used together.
-GRADLE_OPTS="$GRADLE_OPTS -Xmx1024m"
-# JAVA_OPTS="$JAVA_OPTS -Xmx512"
+# GRADLE_OPTS="$GRADLE_OPTS -Xmx512m"
+# JAVA_OPTS="$JAVA_OPTS -Xmx512m"
GRADLE_APP_NAME=Gradle
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
warn ( ) {
- echo "${PROGNAME}: $*"
+ echo "$*"
}
die ( ) {
- warn "$*"
+ echo
+ echo "$*"
+ echo
exit 1
}
-
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
@@ -79,12 +83,31 @@ if [ -z "$JAVACMD" ] ; then
fi
fi
if [ ! -x "$JAVACMD" ] ; then
- die "JAVA_HOME is not defined correctly, can not execute: $JAVACMD"
+ 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
if [ -z "$JAVA_HOME" ] ; then
warn "JAVA_HOME environment variable is not set"
fi
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; 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"
+ fi
+fi
+
# For Darwin, add GRADLE_APP_NAME to the JAVA_OPTS as -Xdock:name
if $darwin; then
JAVA_OPTS="$JAVA_OPTS -Xdock:name=$GRADLE_APP_NAME"
@@ -135,8 +158,11 @@ if $cygwin ; then
esac
fi
-"$JAVACMD" $JAVA_OPTS $GRADLE_OPTS \
+GRADLE_APP_BASE_NAME=`basename "$0"`
+
+exec "$JAVACMD" $JAVA_OPTS $GRADLE_OPTS \
-classpath "$CLASSPATH" \
+ -Dorg.gradle.appname="$GRADLE_APP_BASE_NAME" \
-Dorg.gradle.wrapper.properties="$WRAPPER_PROPERTIES" \
$STARTER_MAIN_CLASS \
"$@"
diff --git a/gradlew.bat b/gradlew.bat
index 114aaa4..4855abb 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -5,83 +5,39 @@
@rem ##
@rem ##########################################################################
-@rem
-@rem $Revision: 10602 $ $Date: 2008-01-25 02:49:54 +0100 (ven., 25 janv. 2008) $
-@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% -Xmx512
-@rem set JAVA_OPTS=%JAVA_OPTS% -Xmx512
+@rem set GRADLE_OPTS=%GRADLE_OPTS% -Xmx512m
+@rem set JAVA_OPTS=%JAVA_OPTS% -Xmx512m
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.\
-@rem Determine the command interpreter to execute the "CD" later
-set COMMAND_COM="cmd.exe"
-if exist "%SystemRoot%\system32\cmd.exe" set COMMAND_COM="%SystemRoot%\system32\cmd.exe"
-if exist "%SystemRoot%\command.com" set COMMAND_COM="%SystemRoot%\command.com"
+@rem Find java.exe
+set JAVA_EXE=java.exe
+if not defined JAVA_HOME goto init
-@rem Use explicit find.exe to prevent cygwin and others find.exe from being used
-set FIND_EXE="find.exe"
-if exist "%SystemRoot%\system32\find.exe" set FIND_EXE="%SystemRoot%\system32\find.exe"
-if exist "%SystemRoot%\command\find.exe" set FIND_EXE="%SystemRoot%\command\find.exe"
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-:check_JAVA_HOME
-@rem Make sure we have a valid JAVA_HOME
-if not "%JAVA_HOME%" == "" goto have_JAVA_HOME
+if exist "%JAVA_EXE%" goto init
echo.
-echo ERROR: Environment variable JAVA_HOME has not been set.
+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
-:have_JAVA_HOME
-@rem Validate JAVA_HOME
-%COMMAND_COM% /C DIR "%JAVA_HOME%" 2>&1 | %FIND_EXE% /I /C "%JAVA_HOME%" >nul
-if not errorlevel 1 goto init
-
-echo.
-echo ERROR: JAVA_HOME might be 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 if there are problems.
-echo.
-
:init
-@rem get name of script to launch with full path
@rem Get command-line arguments, handling Windowz variants
-SET _marker=%JAVA_HOME: =%
-@rem IF NOT "%_marker%" == "%JAVA_HOME%" ECHO JAVA_HOME "%JAVA_HOME%" contains spaces. Please change to a location without spaces if this causes problems.
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%eval[2+2]" == "4" goto 4NT_args
-IF "%_marker%" == "%JAVA_HOME%" goto :win9xME_args
-
-set _FIXPATH=
-call :fixpath "%JAVA_HOME%"
-set JAVA_HOME=%_FIXPATH:~1%
-
-goto win9xME_args
-
-:fixpath
-if not %1.==. (
-for /f "tokens=1* delims=;" %%a in (%1) do (
-call :shortfilename "%%a" & call :fixpath "%%b"
-)
-)
-goto :EOF
-:shortfilename
-for %%i in (%1) do set _FIXPATH=%_FIXPATH%;%%~fsi
-goto :EOF
-
-
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
@@ -103,10 +59,10 @@ set CMD_LINE_ARGS=%$
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 JAVA_EXE=%JAVA_HOME%\bin\java.exe
set GRADLE_OPTS=%JAVA_OPTS% %GRADLE_OPTS% -Dorg.gradle.wrapper.properties="%WRAPPER_PROPERTIES%"
+@rem Execute Gradle
"%JAVA_EXE%" %GRADLE_OPTS% -classpath "%CLASSPATH%" %STARTER_MAIN_CLASS% %CMD_LINE_ARGS%
:end
diff --git a/pom.xml b/pom.xml
index ab999ec..54a2657 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,17 +3,17 @@
org.sonatype.ossoss-parent
- 5
+ 74.0.0jarredis.clientsjedis
- 2.0.1-SNAPSHOT
+ 2.2.0-SNAPSHOTJedisJedis is a blazingly small and sane Redis java client.
- http://code.google.com/p/jedis/
+ https://github.com/xetorthio/jedis
@@ -27,7 +27,7 @@
- Jedis License
+ MIThttp://github.com/xetorthio/jedis/raw/master/LICENSE.txtrepo
@@ -38,11 +38,11 @@
http://github.com/xetorthio/jedis/issues
-
- http://github.com/xetorthio/jedis
- scm:git:git@github.com:xetorthio/jedis.git
- scm:git:git@github.com:xetorthio/jedis.git
-
+
+ scm:git:git@github.com:xetorthio/jedis.git
+ scm:git:git@github.com:xetorthio/jedis.git
+ scm:git:git@github.com:xetorthio/jedis.git
+ localhost:6379,localhost:6380
@@ -102,6 +102,11 @@
true
+
+ org.apache.maven.plugins
+ maven-release-plugin
+ 2.0-beta-9
+
diff --git a/src/main/java/redis/clients/jedis/AdvancedBinaryJedisCommands.java b/src/main/java/redis/clients/jedis/AdvancedBinaryJedisCommands.java
new file mode 100644
index 0000000..51b4879
--- /dev/null
+++ b/src/main/java/redis/clients/jedis/AdvancedBinaryJedisCommands.java
@@ -0,0 +1,25 @@
+package redis.clients.jedis;
+
+
+import java.util.List;
+
+public interface AdvancedBinaryJedisCommands {
+
+ List configGet(byte[] pattern);
+
+ byte[] configSet(byte[] parameter, byte[] value);
+
+ String slowlogReset();
+
+ Long slowlogLen();
+
+ List slowlogGetBinary();
+
+ List slowlogGetBinary(long entries);
+
+ Long objectRefcount(byte[] key);
+
+ byte[] objectEncoding(byte[] key);
+
+ Long objectIdletime(byte[] key);
+}
diff --git a/src/main/java/redis/clients/jedis/AdvancedJedisCommands.java b/src/main/java/redis/clients/jedis/AdvancedJedisCommands.java
new file mode 100644
index 0000000..5ed50eb
--- /dev/null
+++ b/src/main/java/redis/clients/jedis/AdvancedJedisCommands.java
@@ -0,0 +1,26 @@
+package redis.clients.jedis;
+
+import redis.clients.util.Slowlog;
+
+import java.util.List;
+
+
+public interface AdvancedJedisCommands {
+ List configGet(String pattern);
+
+ String configSet(String parameter, String value);
+
+ String slowlogReset();
+
+ Long slowlogLen();
+
+ List slowlogGet();
+
+ List slowlogGet(long entries);
+
+ Long objectRefcount(String string);
+
+ String objectEncoding(String string);
+
+ Long objectIdletime(String string);
+}
diff --git a/src/main/java/redis/clients/jedis/BasicCommands.java b/src/main/java/redis/clients/jedis/BasicCommands.java
new file mode 100644
index 0000000..482d43b
--- /dev/null
+++ b/src/main/java/redis/clients/jedis/BasicCommands.java
@@ -0,0 +1,42 @@
+package redis.clients.jedis;
+
+public interface BasicCommands {
+
+ String ping();
+
+ String quit();
+
+ String flushDB();
+
+ Long dbSize();
+
+ String select(int index);
+
+ String flushAll();
+
+ String auth(String password);
+
+ String save();
+
+ String bgsave();
+
+ String bgrewriteaof();
+
+ Long lastsave();
+
+ String shutdown();
+
+ String info();
+
+ String info(String section);
+
+ String slaveof(String host, int port);
+
+ String slaveofNoOne();
+
+ Long getDB();
+
+ String debug(DebugParams params);
+
+ String configResetStat();
+}
diff --git a/src/main/java/redis/clients/jedis/BasicRedisPipeline.java b/src/main/java/redis/clients/jedis/BasicRedisPipeline.java
new file mode 100644
index 0000000..97658d8
--- /dev/null
+++ b/src/main/java/redis/clients/jedis/BasicRedisPipeline.java
@@ -0,0 +1,38 @@
+package redis.clients.jedis;
+
+
+import java.util.List;
+
+/**
+ * Pipelined responses for all of the low level, non key related commands
+ */
+public interface BasicRedisPipeline {
+
+ Response bgrewriteaof();
+
+ Response bgsave();
+
+ Response configGet(String pattern);
+
+ Response configSet(String parameter, String value);
+
+ Response configResetStat();
+
+ Response save();
+
+ Response lastsave();
+
+ Response flushDB();
+
+ Response flushAll();
+
+ Response info();
+
+ Response dbSize();
+
+ Response shutdown();
+
+ Response ping();
+
+ Response select(int index);
+}
diff --git a/src/main/java/redis/clients/jedis/BinaryClient.java b/src/main/java/redis/clients/jedis/BinaryClient.java
index c982151..4d21f7a 100644
--- a/src/main/java/redis/clients/jedis/BinaryClient.java
+++ b/src/main/java/redis/clients/jedis/BinaryClient.java
@@ -2,15 +2,21 @@ package redis.clients.jedis;
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 redis.clients.jedis.Protocol.Command;
import redis.clients.jedis.Protocol.Keyword;
@@ -18,12 +24,12 @@ import redis.clients.util.SafeEncoder;
public class BinaryClient extends Connection {
public enum LIST_POSITION {
- BEFORE, AFTER;
- public final byte[] raw;
+ BEFORE, AFTER;
+ public final byte[] raw;
- private LIST_POSITION() {
- raw = SafeEncoder.encode(name());
- }
+ private LIST_POSITION() {
+ raw = SafeEncoder.encode(name());
+ }
}
private boolean isInMulti;
@@ -33,462 +39,506 @@ public class BinaryClient extends Connection {
private long db;
public boolean isInMulti() {
- return isInMulti;
+ return isInMulti;
}
public BinaryClient(final String host) {
- super(host);
+ super(host);
}
public BinaryClient(final String host, final int port) {
- super(host, port);
+ super(host, port);
+ }
+
+ private byte[][] joinParameters(byte[] first, byte[][] rest) {
+ byte[][] result = new byte[rest.length + 1][];
+ result[0] = first;
+ for (int i = 0; i < rest.length; i++) {
+ result[i + 1] = rest[i];
+ }
+ return result;
}
public void setPassword(final String password) {
- this.password = password;
+ this.password = password;
}
@Override
public void connect() {
- if (!isConnected()) {
- super.connect();
- if (password != null) {
- auth(password);
- getStatusCodeReply();
- }
- if (db > 0) {
- select(Long.valueOf(db).intValue());
- getStatusCodeReply();
- }
- }
+ if (!isConnected()) {
+ super.connect();
+ if (password != null) {
+ auth(password);
+ getStatusCodeReply();
+ }
+ if (db > 0) {
+ select(Long.valueOf(db).intValue());
+ getStatusCodeReply();
+ }
+ }
}
public void ping() {
- sendCommand(PING);
+ sendCommand(Command.PING);
}
public void set(final byte[] key, final byte[] value) {
- sendCommand(Command.SET, key, value);
+ sendCommand(Command.SET, key, value);
}
public void get(final byte[] key) {
- sendCommand(Command.GET, key);
+ sendCommand(Command.GET, key);
}
public void quit() {
- db = 0;
- sendCommand(QUIT);
+ db = 0;
+ sendCommand(QUIT);
}
public void exists(final byte[] key) {
- sendCommand(EXISTS, key);
+ sendCommand(EXISTS, key);
}
public void del(final byte[]... keys) {
- sendCommand(DEL, keys);
+ sendCommand(DEL, keys);
}
public void type(final byte[] key) {
- sendCommand(TYPE, key);
+ sendCommand(TYPE, key);
}
public void flushDB() {
- sendCommand(FLUSHDB);
+ sendCommand(FLUSHDB);
}
public void keys(final byte[] pattern) {
- sendCommand(KEYS, pattern);
+ sendCommand(KEYS, pattern);
}
public void randomKey() {
- sendCommand(RANDOMKEY);
+ sendCommand(RANDOMKEY);
}
public void rename(final byte[] oldkey, final byte[] newkey) {
- sendCommand(RENAME, oldkey, newkey);
+ sendCommand(RENAME, oldkey, newkey);
}
public void renamenx(final byte[] oldkey, final byte[] newkey) {
- sendCommand(RENAMENX, oldkey, newkey);
+ sendCommand(RENAMENX, oldkey, newkey);
}
public void dbSize() {
- sendCommand(DBSIZE);
+ sendCommand(DBSIZE);
}
public void expire(final byte[] key, final int seconds) {
- sendCommand(EXPIRE, key, toByteArray(seconds));
+ sendCommand(EXPIRE, key, toByteArray(seconds));
}
public void expireAt(final byte[] key, final long unixTime) {
- sendCommand(EXPIREAT, key, toByteArray(unixTime));
+ sendCommand(EXPIREAT, key, toByteArray(unixTime));
}
public void ttl(final byte[] key) {
- sendCommand(TTL, key);
+ sendCommand(TTL, key);
}
public void select(final int index) {
- db = index;
- sendCommand(SELECT, toByteArray(index));
+ db = index;
+ sendCommand(SELECT, toByteArray(index));
}
public void move(final byte[] key, final int dbIndex) {
- sendCommand(MOVE, key, toByteArray(dbIndex));
+ sendCommand(MOVE, key, toByteArray(dbIndex));
}
public void flushAll() {
- sendCommand(FLUSHALL);
+ sendCommand(FLUSHALL);
}
public void getSet(final byte[] key, final byte[] value) {
- sendCommand(GETSET, key, value);
+ sendCommand(GETSET, key, value);
}
public void mget(final byte[]... keys) {
- sendCommand(MGET, keys);
+ sendCommand(MGET, keys);
}
public void setnx(final byte[] key, final byte[] value) {
- sendCommand(SETNX, key, value);
+ sendCommand(SETNX, key, value);
}
public void setex(final byte[] key, final int seconds, final byte[] value) {
- sendCommand(SETEX, key, toByteArray(seconds), value);
+ sendCommand(SETEX, key, toByteArray(seconds), value);
}
public void mset(final byte[]... keysvalues) {
- sendCommand(MSET, keysvalues);
+ sendCommand(MSET, keysvalues);
}
public void msetnx(final byte[]... keysvalues) {
- sendCommand(MSETNX, keysvalues);
+ sendCommand(MSETNX, keysvalues);
}
public void decrBy(final byte[] key, final long integer) {
- sendCommand(DECRBY, key, toByteArray(integer));
+ sendCommand(DECRBY, key, toByteArray(integer));
}
public void decr(final byte[] key) {
- sendCommand(DECR, key);
+ sendCommand(DECR, key);
}
public void incrBy(final byte[] key, final long integer) {
- sendCommand(INCRBY, key, toByteArray(integer));
+ sendCommand(INCRBY, key, toByteArray(integer));
}
public void incr(final byte[] key) {
- sendCommand(INCR, key);
+ sendCommand(INCR, key);
}
public void append(final byte[] key, final byte[] value) {
- sendCommand(APPEND, key, value);
+ sendCommand(APPEND, key, value);
}
public void substr(final byte[] key, final int start, final int end) {
- sendCommand(SUBSTR, key, toByteArray(start), toByteArray(end));
+ sendCommand(SUBSTR, key, toByteArray(start), toByteArray(end));
}
public void hset(final byte[] key, final byte[] field, final byte[] value) {
- sendCommand(HSET, key, field, value);
+ sendCommand(HSET, key, field, value);
}
public void hget(final byte[] key, final byte[] field) {
- sendCommand(HGET, key, field);
+ sendCommand(HGET, key, field);
}
public void hsetnx(final byte[] key, final byte[] field, final byte[] value) {
- sendCommand(HSETNX, key, field, value);
+ sendCommand(HSETNX, key, field, value);
}
public void hmset(final byte[] key, final Map hash) {
- final List params = new ArrayList();
- params.add(key);
+ final List params = new ArrayList();
+ params.add(key);
- for (final byte[] field : hash.keySet()) {
- params.add(field);
- params.add(hash.get(field));
- }
- sendCommand(HMSET, params.toArray(new byte[params.size()][]));
+ for (final Entry entry : hash.entrySet()) {
+ params.add(entry.getKey());
+ params.add(entry.getValue());
+ }
+ sendCommand(HMSET, params.toArray(new byte[params.size()][]));
}
public void hmget(final byte[] key, final byte[]... fields) {
- final byte[][] params = new byte[fields.length + 1][];
- params[0] = key;
- System.arraycopy(fields, 0, params, 1, fields.length);
- sendCommand(HMGET, params);
+ final byte[][] params = new byte[fields.length + 1][];
+ params[0] = key;
+ System.arraycopy(fields, 0, params, 1, fields.length);
+ sendCommand(HMGET, params);
}
public void hincrBy(final byte[] key, final byte[] field, final long value) {
- sendCommand(HINCRBY, key, field, toByteArray(value));
+ sendCommand(HINCRBY, key, field, toByteArray(value));
}
public void hexists(final byte[] key, final byte[] field) {
- sendCommand(HEXISTS, key, field);
+ sendCommand(HEXISTS, key, field);
}
- public void hdel(final byte[] key, final byte[] field) {
- sendCommand(HDEL, key, field);
+ public void hdel(final byte[] key, final byte[]... fields) {
+ sendCommand(HDEL, joinParameters(key, fields));
}
public void hlen(final byte[] key) {
- sendCommand(HLEN, key);
+ sendCommand(HLEN, key);
}
public void hkeys(final byte[] key) {
- sendCommand(HKEYS, key);
+ sendCommand(HKEYS, key);
}
public void hvals(final byte[] key) {
- sendCommand(HVALS, key);
+ sendCommand(HVALS, key);
}
public void hgetAll(final byte[] key) {
- sendCommand(HGETALL, key);
+ sendCommand(HGETALL, key);
}
- public void rpush(final byte[] key, final byte[] string) {
- sendCommand(RPUSH, key, string);
+ public void rpush(final byte[] key, final byte[]... strings) {
+ sendCommand(RPUSH, joinParameters(key, strings));
}
- public void lpush(final byte[] key, final byte[] string) {
- sendCommand(LPUSH, key, string);
+ public void lpush(final byte[] key, final byte[]... strings) {
+ sendCommand(LPUSH, joinParameters(key, strings));
}
public void llen(final byte[] key) {
- sendCommand(LLEN, key);
+ sendCommand(LLEN, key);
}
public void lrange(final byte[] key, final long start, final long end) {
- sendCommand(LRANGE, key, toByteArray(start), toByteArray(end));
+ sendCommand(LRANGE, key, toByteArray(start), toByteArray(end));
}
public void ltrim(final byte[] key, final long start, final long end) {
- sendCommand(LTRIM, key, toByteArray(start), toByteArray(end));
+ sendCommand(LTRIM, key, toByteArray(start), toByteArray(end));
}
public void lindex(final byte[] key, final long index) {
- sendCommand(LINDEX, key, toByteArray(index));
+ sendCommand(LINDEX, key, toByteArray(index));
}
public void lset(final byte[] key, final long index, final byte[] value) {
- sendCommand(LSET, key, toByteArray(index), value);
+ sendCommand(LSET, key, toByteArray(index), value);
}
public void lrem(final byte[] key, long count, final byte[] value) {
- sendCommand(LREM, key, toByteArray(count), value);
+ sendCommand(LREM, key, toByteArray(count), value);
}
public void lpop(final byte[] key) {
- sendCommand(LPOP, key);
+ sendCommand(LPOP, key);
}
public void rpop(final byte[] key) {
- sendCommand(RPOP, key);
+ sendCommand(RPOP, key);
}
public void rpoplpush(final byte[] srckey, final byte[] dstkey) {
- sendCommand(RPOPLPUSH, srckey, dstkey);
+ sendCommand(RPOPLPUSH, srckey, dstkey);
}
- public void sadd(final byte[] key, final byte[] member) {
- sendCommand(SADD, key, member);
+ public void sadd(final byte[] key, final byte[]... members) {
+ sendCommand(SADD, joinParameters(key, members));
}
public void smembers(final byte[] key) {
- sendCommand(SMEMBERS, key);
+ sendCommand(SMEMBERS, key);
}
- public void srem(final byte[] key, final byte[] member) {
- sendCommand(SREM, key, member);
+ public void srem(final byte[] key, final byte[]... members) {
+ sendCommand(SREM, joinParameters(key, members));
}
public void spop(final byte[] key) {
- sendCommand(SPOP, key);
+ sendCommand(SPOP, key);
}
public void smove(final byte[] srckey, final byte[] dstkey,
- final byte[] member) {
- sendCommand(SMOVE, srckey, dstkey, member);
+ final byte[] member) {
+ sendCommand(SMOVE, srckey, dstkey, member);
}
public void scard(final byte[] key) {
- sendCommand(SCARD, key);
+ sendCommand(SCARD, key);
}
public void sismember(final byte[] key, final byte[] member) {
- sendCommand(SISMEMBER, key, member);
+ sendCommand(SISMEMBER, key, member);
}
public void sinter(final byte[]... keys) {
- sendCommand(SINTER, keys);
+ sendCommand(SINTER, keys);
}
public void sinterstore(final byte[] dstkey, final byte[]... keys) {
- final byte[][] params = new byte[keys.length + 1][];
- params[0] = dstkey;
- System.arraycopy(keys, 0, params, 1, keys.length);
- sendCommand(SINTERSTORE, params);
+ final byte[][] params = new byte[keys.length + 1][];
+ params[0] = dstkey;
+ System.arraycopy(keys, 0, params, 1, keys.length);
+ sendCommand(SINTERSTORE, params);
}
public void sunion(final byte[]... keys) {
- sendCommand(SUNION, keys);
+ sendCommand(SUNION, keys);
}
public void sunionstore(final byte[] dstkey, final byte[]... keys) {
- byte[][] params = new byte[keys.length + 1][];
- params[0] = dstkey;
- System.arraycopy(keys, 0, params, 1, keys.length);
- sendCommand(SUNIONSTORE, params);
+ byte[][] params = new byte[keys.length + 1][];
+ params[0] = dstkey;
+ System.arraycopy(keys, 0, params, 1, keys.length);
+ sendCommand(SUNIONSTORE, params);
}
public void sdiff(final byte[]... keys) {
- sendCommand(SDIFF, keys);
+ sendCommand(SDIFF, keys);
}
public void sdiffstore(final byte[] dstkey, final byte[]... keys) {
- byte[][] params = new byte[keys.length + 1][];
- params[0] = dstkey;
- System.arraycopy(keys, 0, params, 1, keys.length);
- sendCommand(SDIFFSTORE, params);
+ byte[][] params = new byte[keys.length + 1][];
+ params[0] = dstkey;
+ System.arraycopy(keys, 0, params, 1, keys.length);
+ sendCommand(SDIFFSTORE, params);
}
public void srandmember(final byte[] key) {
- sendCommand(SRANDMEMBER, key);
+ sendCommand(SRANDMEMBER, key);
}
public void zadd(final byte[] key, final double score, final byte[] member) {
- sendCommand(ZADD, key, toByteArray(score), member);
+ sendCommand(ZADD, key, toByteArray(score), member);
}
- public void zrange(final byte[] key, final int start, final int end) {
- sendCommand(ZRANGE, key, toByteArray(start), toByteArray(end));
+ public void zaddBinary(final byte[] key, 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());
+ }
+
+ byte[][] argsArray = new byte[args.size()][];
+ args.toArray(argsArray);
+
+ sendCommand(ZADD, argsArray);
}
- public void zrem(final byte[] key, final byte[] member) {
- sendCommand(ZREM, key, member);
+ public void zrange(final byte[] key, final long start, final long end) {
+ sendCommand(ZRANGE, key, toByteArray(start), toByteArray(end));
+ }
+
+ public void zrem(final byte[] key, final byte[]... members) {
+ sendCommand(ZREM, joinParameters(key, members));
}
public void zincrby(final byte[] key, final double score,
- final byte[] member) {
- sendCommand(ZINCRBY, key, toByteArray(score), member);
+ final byte[] member) {
+ sendCommand(ZINCRBY, key, toByteArray(score), member);
}
public void zrank(final byte[] key, final byte[] member) {
- sendCommand(ZRANK, key, member);
+ sendCommand(ZRANK, key, member);
}
public void zrevrank(final byte[] key, final byte[] member) {
- sendCommand(ZREVRANK, key, member);
+ sendCommand(ZREVRANK, key, member);
}
- public void zrevrange(final byte[] key, final int start, final int end) {
- sendCommand(ZREVRANGE, key, toByteArray(start), toByteArray(end));
+ public void zrevrange(final byte[] key, final long start, final long end) {
+ sendCommand(ZREVRANGE, key, toByteArray(start), toByteArray(end));
}
- public void zrangeWithScores(final byte[] key, final int start,
- final int end) {
- sendCommand(ZRANGE, key, toByteArray(start), toByteArray(end),
- WITHSCORES.raw);
+ public void zrangeWithScores(final byte[] key, final long start,
+ final long end) {
+ sendCommand(ZRANGE, key, toByteArray(start), toByteArray(end),
+ WITHSCORES.raw);
}
- public void zrevrangeWithScores(final byte[] key, final int start,
- final int end) {
- sendCommand(ZREVRANGE, key, toByteArray(start), toByteArray(end),
- WITHSCORES.raw);
+ public void zrevrangeWithScores(final byte[] key, final long start,
+ final long end) {
+ sendCommand(ZREVRANGE, key, toByteArray(start), toByteArray(end),
+ WITHSCORES.raw);
}
public void zcard(final byte[] key) {
- sendCommand(ZCARD, key);
+ sendCommand(ZCARD, key);
}
public void zscore(final byte[] key, final byte[] member) {
- sendCommand(ZSCORE, key, member);
+ sendCommand(ZSCORE, key, member);
}
public void multi() {
- sendCommand(MULTI);
- isInMulti = true;
+ sendCommand(MULTI);
+ isInMulti = true;
}
public void discard() {
- sendCommand(DISCARD);
- isInMulti = false;
+ sendCommand(DISCARD);
+ isInMulti = false;
}
public void exec() {
- sendCommand(EXEC);
- isInMulti = false;
+ sendCommand(EXEC);
+ isInMulti = false;
}
public void watch(final byte[]... keys) {
- sendCommand(WATCH, keys);
+ sendCommand(WATCH, keys);
}
public void unwatch() {
- sendCommand(UNWATCH);
+ sendCommand(UNWATCH);
}
public void sort(final byte[] key) {
- sendCommand(SORT, key);
+ sendCommand(SORT, key);
}
public void sort(final byte[] key, final SortingParams sortingParameters) {
- final List args = new ArrayList();
- args.add(key);
- args.addAll(sortingParameters.getParams());
- sendCommand(SORT, args.toArray(new byte[args.size()][]));
+ final List args = new ArrayList();
+ args.add(key);
+ args.addAll(sortingParameters.getParams());
+ sendCommand(SORT, args.toArray(new byte[args.size()][]));
}
public void blpop(final byte[][] args) {
- sendCommand(BLPOP, 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()][]));
}
public void sort(final byte[] key, final SortingParams sortingParameters,
- final byte[] dstkey) {
- final List args = new ArrayList();
- args.add(key);
- args.addAll(sortingParameters.getParams());
- args.add(STORE.raw);
- args.add(dstkey);
- sendCommand(SORT, args.toArray(new byte[args.size()][]));
+ final byte[] dstkey) {
+ final List args = new ArrayList();
+ args.add(key);
+ args.addAll(sortingParameters.getParams());
+ args.add(STORE.raw);
+ args.add(dstkey);
+ sendCommand(SORT, args.toArray(new byte[args.size()][]));
}
public void sort(final byte[] key, final byte[] dstkey) {
- sendCommand(SORT, key, STORE.raw, dstkey);
+ sendCommand(SORT, key, STORE.raw, dstkey);
}
public void brpop(final byte[][] args) {
- sendCommand(BRPOP, 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()][]));
}
public void auth(final String password) {
- setPassword(password);
- sendCommand(AUTH, password);
+ setPassword(password);
+ sendCommand(AUTH, password);
}
public void subscribe(final byte[]... channels) {
- sendCommand(SUBSCRIBE, channels);
+ sendCommand(SUBSCRIBE, channels);
}
public void publish(final byte[] channel, final byte[] message) {
- sendCommand(PUBLISH, channel, message);
+ sendCommand(PUBLISH, channel, message);
}
public void unsubscribe() {
- sendCommand(UNSUBSCRIBE);
+ sendCommand(UNSUBSCRIBE);
}
public void unsubscribe(final byte[]... channels) {
- sendCommand(UNSUBSCRIBE, channels);
+ sendCommand(UNSUBSCRIBE, channels);
}
public void psubscribe(final byte[]... patterns) {
- sendCommand(PSUBSCRIBE, patterns);
+ sendCommand(PSUBSCRIBE, patterns);
}
public void punsubscribe() {
- sendCommand(PUNSUBSCRIBE);
+ sendCommand(PUNSUBSCRIBE);
}
public void punsubscribe(final byte[]... patterns) {
@@ -521,8 +571,8 @@ public class BinaryClient extends Connection {
}
public void zrangeByScore(final byte[] key, final byte[] min,
- final byte[] max) {
- sendCommand(ZRANGEBYSCORE, key, min, max);
+ final byte[] max) {
+ sendCommand(ZRANGEBYSCORE, key, min, max);
}
public void zrangeByScore(final byte[] key, final String min,
@@ -540,8 +590,8 @@ public class BinaryClient extends Connection {
}
public void zrevrangeByScore(final byte[] key, final byte[] max,
- final byte[] min) {
- sendCommand(ZREVRANGEBYSCORE, key, max, min);
+ final byte[] min) {
+ sendCommand(ZREVRANGEBYSCORE, key, max, min);
}
public void zrevrangeByScore(final byte[] key, final String max,
@@ -558,14 +608,7 @@ public class BinaryClient extends Connection {
sendCommand(ZRANGEBYSCORE, key, byteArrayMin, byteArrayMax,
LIMIT.raw, toByteArray(offset), toByteArray(count));
}
-
- public void zrangeByScore(final byte[] key, final byte min[],
- final byte max[], final int offset, int count) {
-
- sendCommand(ZRANGEBYSCORE, key, min, max,
- LIMIT.raw, toByteArray(offset), toByteArray(count));
- }
-
+
public void zrangeByScore(final byte[] key, final String min,
final String max, final int offset, int count) {
@@ -581,14 +624,7 @@ public class BinaryClient extends Connection {
sendCommand(ZREVRANGEBYSCORE, key, byteArrayMax, byteArrayMin,
LIMIT.raw, toByteArray(offset), toByteArray(count));
- }
-
- public void zrevrangeByScore(final byte[] key, final byte max[],
- final byte min[], final int offset, int count) {
-
- sendCommand(ZREVRANGEBYSCORE, key, max, min,
- LIMIT.raw, toByteArray(offset), toByteArray(count));
- }
+ }
public void zrevrangeByScore(final byte[] key, final String max,
final String min, final int offset, int count) {
@@ -607,13 +643,6 @@ public class BinaryClient extends Connection {
WITHSCORES.raw);
}
- public void zrangeByScoreWithScores(final byte[] key, final byte min[],
- final byte max[]) {
-
- sendCommand(ZRANGEBYSCORE, key, min, max,
- WITHSCORES.raw);
- }
-
public void zrangeByScoreWithScores(final byte[] key, final String min,
final String max) {
@@ -631,12 +660,6 @@ public class BinaryClient extends Connection {
WITHSCORES.raw);
}
- public void zrevrangeByScoreWithScores(final byte[] key, final byte max[],
- final byte min[]) {
- sendCommand(ZREVRANGEBYSCORE, key, max, min,
- WITHSCORES.raw);
- }
-
public void zrevrangeByScoreWithScores(final byte[] key, final String max,
final String min) {
sendCommand(ZREVRANGEBYSCORE, key, max.getBytes(), min.getBytes(),
@@ -654,13 +677,6 @@ public class BinaryClient extends Connection {
WITHSCORES.raw);
}
- public void zrangeByScoreWithScores(final byte[] key, final byte min[],
- final byte max[], final int offset, final int count) {
- sendCommand(ZRANGEBYSCORE, key, min, max,
- 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(),
@@ -679,14 +695,6 @@ public class BinaryClient extends Connection {
WITHSCORES.raw);
}
- public void zrevrangeByScoreWithScores(final byte[] key, final byte max[],
- final byte min[], final int offset, final int count) {
-
- sendCommand(ZREVRANGEBYSCORE, key, max, min,
- 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) {
@@ -694,175 +702,401 @@ public class BinaryClient extends Connection {
LIMIT.raw, toByteArray(offset), toByteArray(count),
WITHSCORES.raw);
}
-
- public void zremrangeByRank(final byte[] key, final int start, final int end) {
- sendCommand(ZREMRANGEBYRANK, key, toByteArray(start), toByteArray(end));
+
+ public void zrangeByScore(final byte[] key, final byte[] min,
+ final byte[] max, final int offset, int count) {
+ sendCommand(ZRANGEBYSCORE, key, min, max, LIMIT.raw,
+ toByteArray(offset), toByteArray(count));
}
- public void zremrangeByScore(final byte[] key, final double start,
- final double end) {
- sendCommand(ZREMRANGEBYSCORE, key, toByteArray(start), toByteArray(end));
+ public void zrevrangeByScore(final byte[] key, final byte[] max,
+ final byte[] min, final int offset, int count) {
+ sendCommand(ZREVRANGEBYSCORE, key, max, min, LIMIT.raw,
+ toByteArray(offset), toByteArray(count));
}
- public void zremrangeByScore(final byte[] key, final byte start[],
- final byte end[]) {
- sendCommand(ZREMRANGEBYSCORE, key, start, end);
+ public void zrangeByScoreWithScores(final byte[] key, final byte[] min,
+ final byte[] max) {
+ sendCommand(ZRANGEBYSCORE, key, min, max, WITHSCORES.raw);
}
+ public void zrevrangeByScoreWithScores(final byte[] key, final byte[] max,
+ final byte[] min) {
+ sendCommand(ZREVRANGEBYSCORE, key, max, min, WITHSCORES.raw);
+ }
+
+ public void zrangeByScoreWithScores(final byte[] key, final byte[] min,
+ final byte[] max, final int offset, final int count) {
+ sendCommand(ZRANGEBYSCORE, key, min, max, LIMIT.raw,
+ toByteArray(offset), toByteArray(count), WITHSCORES.raw);
+ }
+
+ public void zrevrangeByScoreWithScores(final byte[] key, final byte[] max,
+ final byte[] min, final int offset, final int count) {
+ sendCommand(ZREVRANGEBYSCORE, key, max, min, LIMIT.raw,
+ toByteArray(offset), toByteArray(count), WITHSCORES.raw);
+ }
+
+ public void zremrangeByRank(final byte[] key, final long start,
+ final long end) {
+ sendCommand(ZREMRANGEBYRANK, key, toByteArray(start), toByteArray(end));
+ }
+
+ 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());
}
public void zunionstore(final byte[] dstkey, final byte[]... sets) {
- final byte[][] params = new byte[sets.length + 2][];
- params[0] = dstkey;
- params[1] = toByteArray(sets.length);
- System.arraycopy(sets, 0, params, 2, sets.length);
- sendCommand(ZUNIONSTORE, params);
+ final byte[][] params = new byte[sets.length + 2][];
+ params[0] = dstkey;
+ params[1] = toByteArray(sets.length);
+ System.arraycopy(sets, 0, params, 2, sets.length);
+ sendCommand(ZUNIONSTORE, params);
}
public void zunionstore(final byte[] dstkey, final ZParams params,
- final byte[]... sets) {
- final List args = new ArrayList();
- args.add(dstkey);
- args.add(Protocol.toByteArray(sets.length));
- for (final byte[] set : sets) {
- args.add(set);
- }
- args.addAll(params.getParams());
- sendCommand(ZUNIONSTORE, args.toArray(new byte[args.size()][]));
+ final byte[]... sets) {
+ final List args = new ArrayList();
+ args.add(dstkey);
+ args.add(Protocol.toByteArray(sets.length));
+ for (final byte[] set : sets) {
+ args.add(set);
+ }
+ args.addAll(params.getParams());
+ sendCommand(ZUNIONSTORE, args.toArray(new byte[args.size()][]));
}
public void zinterstore(final byte[] dstkey, final byte[]... sets) {
- final byte[][] params = new byte[sets.length + 2][];
- params[0] = dstkey;
- params[1] = Protocol.toByteArray(sets.length);
- System.arraycopy(sets, 0, params, 2, sets.length);
- sendCommand(ZINTERSTORE, params);
+ final byte[][] params = new byte[sets.length + 2][];
+ params[0] = dstkey;
+ params[1] = Protocol.toByteArray(sets.length);
+ System.arraycopy(sets, 0, params, 2, sets.length);
+ sendCommand(ZINTERSTORE, params);
}
public void zinterstore(final byte[] dstkey, final ZParams params,
- final byte[]... sets) {
- final List args = new ArrayList();
- args.add(dstkey);
- args.add(Protocol.toByteArray(sets.length));
- for (final byte[] set : sets) {
- args.add(set);
- }
- args.addAll(params.getParams());
- sendCommand(ZINTERSTORE, args.toArray(new byte[args.size()][]));
+ final byte[]... sets) {
+ final List args = new ArrayList();
+ args.add(dstkey);
+ args.add(Protocol.toByteArray(sets.length));
+ for (final byte[] set : sets) {
+ args.add(set);
+ }
+ args.addAll(params.getParams());
+ sendCommand(ZINTERSTORE, args.toArray(new byte[args.size()][]));
}
public void save() {
- sendCommand(SAVE);
+ sendCommand(SAVE);
}
public void bgsave() {
- sendCommand(BGSAVE);
+ sendCommand(BGSAVE);
}
public void bgrewriteaof() {
- sendCommand(BGREWRITEAOF);
+ sendCommand(BGREWRITEAOF);
}
public void lastsave() {
- sendCommand(LASTSAVE);
+ sendCommand(LASTSAVE);
}
public void shutdown() {
- sendCommand(SHUTDOWN);
+ sendCommand(SHUTDOWN);
}
public void info() {
- sendCommand(INFO);
+ sendCommand(INFO);
+ }
+
+ public void info(final String section) {
+ sendCommand(INFO, section);
}
public void monitor() {
- sendCommand(MONITOR);
+ sendCommand(MONITOR);
}
public void slaveof(final String host, final int port) {
- sendCommand(SLAVEOF, host, String.valueOf(port));
+ sendCommand(SLAVEOF, host, String.valueOf(port));
}
public void slaveofNoOne() {
- sendCommand(SLAVEOF, NO.raw, ONE.raw);
+ sendCommand(SLAVEOF, NO.raw, ONE.raw);
}
- public void configGet(final String pattern) {
- sendCommand(CONFIG, Keyword.GET.name(), pattern);
+ public void configGet(final byte[] pattern) {
+ sendCommand(CONFIG, Keyword.GET.raw, pattern);
}
- public void configSet(final String parameter, final String value) {
- sendCommand(CONFIG, Keyword.SET.name(), parameter, value);
+ public void configSet(final byte[] parameter, final byte[] value) {
+ sendCommand(CONFIG, Keyword.SET.raw, parameter, value);
}
public void strlen(final byte[] key) {
- sendCommand(STRLEN, key);
+ sendCommand(STRLEN, key);
}
public void sync() {
- sendCommand(SYNC);
+ sendCommand(SYNC);
}
- public void lpushx(final byte[] key, final byte[] string) {
- sendCommand(LPUSHX, key, string);
+ public void lpushx(final byte[] key, final byte[]... string) {
+ sendCommand(LPUSHX, joinParameters(key, string));
}
public void persist(final byte[] key) {
- sendCommand(PERSIST, key);
+ sendCommand(PERSIST, key);
}
- public void rpushx(final byte[] key, final byte[] string) {
- sendCommand(RPUSHX, key, string);
+ public void rpushx(final byte[] key, final byte[]... string) {
+ sendCommand(RPUSHX, joinParameters(key, string));
}
public void echo(final byte[] string) {
- sendCommand(ECHO, string);
+ sendCommand(ECHO, string);
}
public void linsert(final byte[] key, final LIST_POSITION where,
- final byte[] pivot, final byte[] value) {
- sendCommand(LINSERT, key, where.raw, pivot, value);
+ final byte[] pivot, final byte[] value) {
+ sendCommand(LINSERT, key, where.raw, pivot, value);
}
public void debug(final DebugParams params) {
- sendCommand(DEBUG, params.getCommand());
+ sendCommand(DEBUG, params.getCommand());
}
public void brpoplpush(final byte[] source, final byte[] destination,
- final int timeout) {
- sendCommand(BRPOPLPUSH, source, destination, toByteArray(timeout));
+ final int timeout) {
+ sendCommand(BRPOPLPUSH, source, destination, toByteArray(timeout));
}
public void configResetStat() {
- sendCommand(CONFIG, Keyword.RESETSTAT.name());
+ sendCommand(CONFIG, Keyword.RESETSTAT.name());
}
public void setbit(byte[] key, long offset, byte[] value) {
- sendCommand(SETBIT, key, toByteArray(offset), value);
+ sendCommand(SETBIT, key, toByteArray(offset), value);
+ }
+
+ public void setbit(byte[] key, long offset, boolean value) {
+ sendCommand(SETBIT, key, toByteArray(offset), toByteArray(value));
}
public void getbit(byte[] key, long offset) {
- sendCommand(GETBIT, key, toByteArray(offset));
+ sendCommand(GETBIT, key, toByteArray(offset));
}
public void setrange(byte[] key, long offset, byte[] value) {
- sendCommand(SETRANGE, key, toByteArray(offset), value);
+ sendCommand(SETRANGE, key, toByteArray(offset), value);
}
public void getrange(byte[] key, long startOffset, long endOffset) {
- sendCommand(GETRANGE, key, toByteArray(startOffset),
- toByteArray(endOffset));
+ sendCommand(GETRANGE, key, toByteArray(startOffset),
+ toByteArray(endOffset));
}
public Long getDB() {
- return db;
+ return db;
}
public void disconnect() {
- db = 0;
- super.disconnect();
+ db = 0;
+ super.disconnect();
+ }
+
+ private void sendEvalCommand(Command command, byte[] script,
+ byte[] keyCount, byte[][] params) {
+
+ final byte[][] allArgs = new byte[params.length + 2][];
+
+ allArgs[0] = script;
+ allArgs[1] = keyCount;
+
+ for (int i = 0; i < params.length; i++)
+ allArgs[i + 2] = params[i];
+
+ sendCommand(command, allArgs);
+ }
+
+ public void eval(byte[] script, byte[] keyCount, byte[][] params) {
+ sendEvalCommand(EVAL, script, keyCount, params);
+ }
+
+ public void eval(byte[] script, int keyCount, byte[]... params) {
+ eval(script, toByteArray(keyCount), params);
+ }
+
+ public void evalsha(byte[] sha1, byte[] keyCount, byte[]... params) {
+ sendEvalCommand(EVALSHA, sha1, keyCount, params);
+ }
+
+ public void evalsha(byte[] sha1, int keyCount, byte[]... params) {
+ sendEvalCommand(EVALSHA, sha1, toByteArray(keyCount), params);
+ }
+
+ public void scriptFlush() {
+ sendCommand(SCRIPT, Keyword.FLUSH.raw);
+ }
+
+ public void scriptExists(byte[]... sha1) {
+ byte[][] args = new byte[sha1.length + 1][];
+ args[0] = Keyword.EXISTS.raw;
+ for (int i = 0; i < sha1.length; i++)
+ args[i + 1] = sha1[i];
+
+ sendCommand(SCRIPT, args);
+ }
+
+ public void scriptLoad(byte[] script) {
+ sendCommand(SCRIPT, Keyword.LOAD.raw, script);
+ }
+
+ public void scriptKill() {
+ sendCommand(SCRIPT, Keyword.KILL.raw);
+ }
+
+ public void slowlogGet() {
+ sendCommand(SLOWLOG, Keyword.GET.raw);
+ }
+
+ public void slowlogGet(long entries) {
+ sendCommand(SLOWLOG, Keyword.GET.raw, toByteArray(entries));
+ }
+
+ public void slowlogReset() {
+ sendCommand(SLOWLOG, RESET.raw);
+ }
+
+ public void slowlogLen() {
+ sendCommand(SLOWLOG, LEN.raw);
+ }
+
+ public void objectRefcount(byte[] key) {
+ sendCommand(OBJECT, REFCOUNT.raw, key);
+ }
+
+ public void objectIdletime(byte[] key) {
+ sendCommand(OBJECT, IDLETIME.raw, key);
+ }
+
+ public void objectEncoding(byte[] key) {
+ sendCommand(OBJECT, ENCODING.raw, key);
+ }
+
+ public void bitcount(byte[] key) {
+ sendCommand(BITCOUNT, key);
+ }
+
+ public void bitcount(byte[] key, long start, long 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;
+ }
+
+ 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);
+ }
+
+ public void sentinel(final byte[]... args) {
+ sendCommand(SENTINEL, args);
+ }
+
+ public void dump(final byte[] key) {
+ sendCommand(DUMP, key);
+ }
+
+ 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));
+ }
+
+ public void pexpireAt(final byte[] key, final long millisecondsTimestamp) {
+ sendCommand(PEXPIREAT, key, toByteArray(millisecondsTimestamp));
+ }
+
+ public void pttl(final byte[] key) {
+ sendCommand(PTTL, key);
+ }
+
+ public void incrByFloat(final byte[] key, final double 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 set(final byte[] key, final byte[] value, final byte[] 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 srandmember(final byte[] key, final int count) {
+ sendCommand(SRANDMEMBER, key, toByteArray(count));
+ }
+
+ public void clientKill(final byte[] client) {
+ sendCommand(CLIENT, Keyword.KILL.raw, client);
+ }
+
+ public void clientGetname() {
+ sendCommand(CLIENT, Keyword.GETNAME.raw);
+ }
+
+ public void clientList() {
+ sendCommand(CLIENT, Keyword.LIST.raw);
+ }
+
+ public void clientSetname(final byte[] name) {
+ sendCommand(CLIENT, Keyword.SETNAME.raw, name);
+ }
+
+ public void 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 hincrByFloat(final byte[] key, final byte[] field, double increment) {
+ sendCommand(HINCRBYFLOAT, key, field, toByteArray(increment));
}
}
diff --git a/src/main/java/redis/clients/jedis/BinaryJedis.java b/src/main/java/redis/clients/jedis/BinaryJedis.java
index 6b6c626..89b42ae 100644
--- a/src/main/java/redis/clients/jedis/BinaryJedis.java
+++ b/src/main/java/redis/clients/jedis/BinaryJedis.java
@@ -1,5 +1,8 @@
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;
@@ -14,32 +17,49 @@ import redis.clients.jedis.exceptions.JedisException;
import redis.clients.util.JedisByteHashMap;
import redis.clients.util.SafeEncoder;
-public class BinaryJedis implements BinaryJedisCommands {
+public class BinaryJedis implements BasicCommands, BinaryJedisCommands, MultiKeyBinaryCommands, AdvancedBinaryJedisCommands, BinaryScriptingCommands {
protected Client client = null;
public BinaryJedis(final String host) {
- client = new Client(host);
+ URI uri = URI.create(host);
+ if (uri.getScheme() != null && uri.getScheme().equals("redis")) {
+ client = new Client(uri.getHost(), uri.getPort());
+ client.auth(uri.getUserInfo().split(":", 2)[1]);
+ client.getStatusCodeReply();
+ client.select(Integer.parseInt(uri.getPath().split("/", 2)[1]));
+ client.getStatusCodeReply();
+ } else {
+ client = new Client(host);
+ }
}
public BinaryJedis(final String host, final int port) {
- client = new Client(host, port);
+ client = new Client(host, port);
}
public BinaryJedis(final String host, final int port, final int timeout) {
- client = new Client(host, port);
- client.setTimeout(timeout);
+ client = new Client(host, port);
+ client.setTimeout(timeout);
}
public BinaryJedis(final JedisShardInfo shardInfo) {
- client = new Client(shardInfo.getHost(), shardInfo.getPort());
- client.setTimeout(shardInfo.getTimeout());
- client.setPassword(shardInfo.getPassword());
+ client = new Client(shardInfo.getHost(), shardInfo.getPort());
+ client.setTimeout(shardInfo.getTimeout());
+ client.setPassword(shardInfo.getPassword());
+ }
+
+ public BinaryJedis(URI uri) {
+ client = new Client(uri.getHost(), uri.getPort());
+ client.auth(uri.getUserInfo().split(":", 2)[1]);
+ client.getStatusCodeReply();
+ client.select(Integer.parseInt(uri.getPath().split("/", 2)[1]));
+ client.getStatusCodeReply();
}
public String ping() {
- checkIsInMulti();
- client.ping();
- return client.getStatusCodeReply();
+ checkIsInMulti();
+ client.ping();
+ return client.getStatusCodeReply();
}
/**
@@ -53,9 +73,9 @@ public class BinaryJedis implements BinaryJedisCommands {
* @return Status code reply
*/
public String set(final byte[] key, final byte[] value) {
- checkIsInMulti();
- client.set(key, value);
- return client.getStatusCodeReply();
+ checkIsInMulti();
+ client.set(key, value);
+ return client.getStatusCodeReply();
}
/**
@@ -69,23 +89,23 @@ public class BinaryJedis implements BinaryJedisCommands {
* @return Bulk reply
*/
public byte[] get(final byte[] key) {
- checkIsInMulti();
- client.get(key);
- return client.getBinaryBulkReply();
+ checkIsInMulti();
+ client.get(key);
+ return client.getBinaryBulkReply();
}
/**
* Ask the server to silently close the connection.
*/
public String quit() {
- checkIsInMulti();
- client.quit();
- return client.getStatusCodeReply();
+ checkIsInMulti();
+ client.quit();
+ return client.getStatusCodeReply();
}
/**
- * Test if the specified key exists. The command returns "0" if the key
- * exists, otherwise "1" is returned. Note that even keys set with an empty
+ * Test if the specified key exists. The command returns "1" if the key
+ * exists, otherwise "0" is returned. Note that even keys set with an empty
* string as value will return "1".
*
* Time complexity: O(1)
@@ -94,9 +114,9 @@ public class BinaryJedis implements BinaryJedisCommands {
* @return Integer reply, "1" if the key exists, otherwise "0"
*/
public Boolean exists(final byte[] key) {
- checkIsInMulti();
- client.exists(key);
- return client.getIntegerReply() == 1;
+ checkIsInMulti();
+ client.exists(key);
+ return client.getIntegerReply() == 1;
}
/**
@@ -110,9 +130,15 @@ public class BinaryJedis implements BinaryJedisCommands {
* more keys were removed 0 if none of the specified key existed
*/
public Long del(final byte[]... keys) {
- checkIsInMulti();
- client.del(keys);
- return client.getIntegerReply();
+ checkIsInMulti();
+ client.del(keys);
+ return client.getIntegerReply();
+ }
+
+ public Long del(final byte[] key) {
+ checkIsInMulti();
+ client.del(key);
+ return client.getIntegerReply();
}
/**
@@ -130,9 +156,9 @@ public class BinaryJedis implements BinaryJedisCommands {
* contains a Hash value
*/
public String type(final byte[] key) {
- checkIsInMulti();
- client.type(key);
- return client.getStatusCodeReply();
+ checkIsInMulti();
+ client.type(key);
+ return client.getStatusCodeReply();
}
/**
@@ -142,9 +168,9 @@ public class BinaryJedis implements BinaryJedisCommands {
* @return Status code reply
*/
public String flushDB() {
- checkIsInMulti();
- client.flushDB();
- return client.getStatusCodeReply();
+ checkIsInMulti();
+ client.flushDB();
+ return client.getStatusCodeReply();
}
/**
@@ -179,11 +205,11 @@ public class BinaryJedis implements BinaryJedisCommands {
* @return Multi bulk reply
*/
public Set keys(final byte[] pattern) {
- checkIsInMulti();
- client.keys(pattern);
- final HashSet keySet = new HashSet(client
- .getBinaryMultiBulkReply());
- return keySet;
+ checkIsInMulti();
+ client.keys(pattern);
+ final HashSet keySet = new HashSet(
+ client.getBinaryMultiBulkReply());
+ return keySet;
}
/**
@@ -195,9 +221,9 @@ public class BinaryJedis implements BinaryJedisCommands {
* empty string is the database is empty
*/
public byte[] randomBinaryKey() {
- checkIsInMulti();
- client.randomKey();
- return client.getBinaryBulkReply();
+ checkIsInMulti();
+ client.randomKey();
+ return client.getBinaryBulkReply();
}
/**
@@ -212,9 +238,9 @@ public class BinaryJedis implements BinaryJedisCommands {
* @return Status code repy
*/
public String rename(final byte[] oldkey, final byte[] newkey) {
- checkIsInMulti();
- client.rename(oldkey, newkey);
- return client.getStatusCodeReply();
+ checkIsInMulti();
+ client.rename(oldkey, newkey);
+ return client.getStatusCodeReply();
}
/**
@@ -229,9 +255,9 @@ public class BinaryJedis implements BinaryJedisCommands {
* target key already exist
*/
public Long renamenx(final byte[] oldkey, final byte[] newkey) {
- checkIsInMulti();
- client.renamenx(oldkey, newkey);
- return client.getIntegerReply();
+ checkIsInMulti();
+ client.renamenx(oldkey, newkey);
+ return client.getIntegerReply();
}
/**
@@ -240,9 +266,9 @@ public class BinaryJedis implements BinaryJedisCommands {
* @return Integer reply
*/
public Long dbSize() {
- checkIsInMulti();
- client.dbSize();
- return client.getIntegerReply();
+ checkIsInMulti();
+ client.dbSize();
+ return client.getIntegerReply();
}
/**
@@ -258,7 +284,7 @@ public class BinaryJedis implements BinaryJedisCommands {
*
* Since Redis 2.1.3 you can update the value of the timeout of a key
* already having an expire set. It is also possible to undo the expire at
- * all turning the key into a normal key using the {@link #persist(String)
+ * all turning the key into a normal key using the {@link #persist(byte[])
* PERSIST} command.
*
* Time complexity: O(1)
@@ -274,13 +300,13 @@ public class BinaryJedis implements BinaryJedisCommands {
* exist.
*/
public Long expire(final byte[] key, final int seconds) {
- checkIsInMulti();
- client.expire(key, seconds);
- return client.getIntegerReply();
+ checkIsInMulti();
+ client.expire(key, seconds);
+ return client.getIntegerReply();
}
/**
- * EXPIREAT works exctly like {@link #expire(String, int) EXPIRE} but
+ * EXPIREAT works exctly like {@link #expire(byte[], int) EXPIRE} but
* instead to get the number of seconds representing the Time To Live of the
* key as a second argument (that is a relative way of specifing the TTL),
* it takes an absolute one in the form of a UNIX timestamp (Number of
@@ -294,7 +320,7 @@ public class BinaryJedis implements BinaryJedisCommands {
*
* Since Redis 2.1.3 you can update the value of the timeout of a key
* already having an expire set. It is also possible to undo the expire at
- * all turning the key into a normal key using the {@link #persist(String)
+ * all turning the key into a normal key using the {@link #persist(byte[])
* PERSIST} command.
*
* Time complexity: O(1)
@@ -310,14 +336,14 @@ public class BinaryJedis implements BinaryJedisCommands {
* exist.
*/
public Long expireAt(final byte[] key, final long unixTime) {
- checkIsInMulti();
- client.expireAt(key, unixTime);
- return client.getIntegerReply();
+ checkIsInMulti();
+ client.expireAt(key, unixTime);
+ return client.getIntegerReply();
}
/**
* The TTL command returns the remaining time to live in seconds of a key
- * that has an {@link #expire(String, int) EXPIRE} set. This introspection
+ * that has an {@link #expire(byte[], int) EXPIRE} set. This introspection
* capability allows a Redis client to check how many seconds a given key
* will continue to be part of the dataset.
*
@@ -327,9 +353,9 @@ public class BinaryJedis implements BinaryJedisCommands {
* have an associated expire, -1 is returned.
*/
public Long ttl(final byte[] key) {
- checkIsInMulti();
- client.ttl(key);
- return client.getIntegerReply();
+ checkIsInMulti();
+ client.ttl(key);
+ return client.getIntegerReply();
}
/**
@@ -340,9 +366,9 @@ public class BinaryJedis implements BinaryJedisCommands {
* @return Status code reply
*/
public String select(final int index) {
- checkIsInMulti();
- client.select(index);
- return client.getStatusCodeReply();
+ checkIsInMulti();
+ client.select(index);
+ return client.getStatusCodeReply();
}
/**
@@ -359,9 +385,9 @@ public class BinaryJedis implements BinaryJedisCommands {
* found in the current DB.
*/
public Long move(final byte[] key, final int dbIndex) {
- checkIsInMulti();
- client.move(key, dbIndex);
- return client.getIntegerReply();
+ checkIsInMulti();
+ client.move(key, dbIndex);
+ return client.getIntegerReply();
}
/**
@@ -371,9 +397,9 @@ public class BinaryJedis implements BinaryJedisCommands {
* @return Status code reply
*/
public String flushAll() {
- checkIsInMulti();
- client.flushAll();
- return client.getStatusCodeReply();
+ checkIsInMulti();
+ client.flushAll();
+ return client.getStatusCodeReply();
}
/**
@@ -388,9 +414,9 @@ public class BinaryJedis implements BinaryJedisCommands {
* @return Bulk reply
*/
public byte[] getSet(final byte[] key, final byte[] value) {
- checkIsInMulti();
- client.getSet(key, value);
- return client.getBinaryBulkReply();
+ checkIsInMulti();
+ client.getSet(key, value);
+ return client.getBinaryBulkReply();
}
/**
@@ -404,13 +430,13 @@ public class BinaryJedis implements BinaryJedisCommands {
* @return Multi bulk reply
*/
public List mget(final byte[]... keys) {
- checkIsInMulti();
- client.mget(keys);
- return client.getBinaryMultiBulkReply();
+ checkIsInMulti();
+ client.mget(keys);
+ return client.getBinaryMultiBulkReply();
}
/**
- * SETNX works exactly like {@link #set(String, String) SET} with the only
+ * SETNX works exactly like {@link #set(byte[], byte[]) SET} with the only
* difference that if the key already exists no operation is performed.
* SETNX actually means "SET if Not eXists".
*
@@ -422,14 +448,14 @@ public class BinaryJedis implements BinaryJedisCommands {
* was not set
*/
public Long setnx(final byte[] key, final byte[] value) {
- checkIsInMulti();
- client.setnx(key, value);
- return client.getIntegerReply();
+ checkIsInMulti();
+ client.setnx(key, value);
+ return client.getIntegerReply();
}
/**
* The command is exactly equivalent to the following group of commands:
- * {@link #set(String, String) SET} + {@link #expire(String, int) EXPIRE}.
+ * {@link #set(byte[], byte[]) SET} + {@link #expire(byte[], int) EXPIRE}.
* The operation is atomic.
*
* Time complexity: O(1)
@@ -440,9 +466,9 @@ public class BinaryJedis implements BinaryJedisCommands {
* @return Status code reply
*/
public String setex(final byte[] key, final int seconds, final byte[] value) {
- checkIsInMulti();
- client.setex(key, seconds, value);
- return client.getStatusCodeReply();
+ checkIsInMulti();
+ client.setex(key, seconds, value);
+ return client.getStatusCodeReply();
}
/**
@@ -466,9 +492,9 @@ public class BinaryJedis implements BinaryJedisCommands {
* @return Status code reply Basically +OK as MSET can't fail
*/
public String mset(final byte[]... keysvalues) {
- checkIsInMulti();
- client.mset(keysvalues);
- return client.getStatusCodeReply();
+ checkIsInMulti();
+ client.mset(keysvalues);
+ return client.getStatusCodeReply();
}
/**
@@ -493,9 +519,9 @@ public class BinaryJedis implements BinaryJedisCommands {
* no key was set (at least one key already existed)
*/
public Long msetnx(final byte[]... keysvalues) {
- checkIsInMulti();
- client.msetnx(keysvalues);
- return client.getIntegerReply();
+ checkIsInMulti();
+ client.msetnx(keysvalues);
+ return client.getIntegerReply();
}
/**
@@ -511,9 +537,9 @@ public class BinaryJedis implements BinaryJedisCommands {
*
* Time complexity: O(1)
*
- * @see #incr(String)
- * @see #decr(String)
- * @see #incrBy(String, int)
+ * @see #incr(byte[])
+ * @see #decr(byte[])
+ * @see #incrBy(byte[], long)
*
* @param key
* @param integer
@@ -521,9 +547,9 @@ public class BinaryJedis implements BinaryJedisCommands {
* after the increment.
*/
public Long decrBy(final byte[] key, final long integer) {
- checkIsInMulti();
- client.decrBy(key, integer);
- return client.getIntegerReply();
+ checkIsInMulti();
+ client.decrBy(key, integer);
+ return client.getIntegerReply();
}
/**
@@ -540,22 +566,22 @@ public class BinaryJedis implements BinaryJedisCommands {
*
* Time complexity: O(1)
*
- * @see #incr(String)
- * @see #incrBy(String, int)
- * @see #decrBy(String, int)
+ * @see #incr(byte[])
+ * @see #incrBy(byte[], long)
+ * @see #decrBy(byte[], long)
*
* @param key
* @return Integer reply, this commands will reply with the new value of key
* after the increment.
*/
public Long decr(final byte[] key) {
- checkIsInMulti();
- client.decr(key);
- return client.getIntegerReply();
+ checkIsInMulti();
+ client.decr(key);
+ return client.getIntegerReply();
}
/**
- * INCRBY work just like {@link #incr(String) INCR} but instead to increment
+ * INCRBY work just like {@link #incr(byte[]) INCR} but instead to increment
* by 1 the increment is integer.
*
* INCR commands are limited to 64 bit signed integers.
@@ -567,9 +593,9 @@ public class BinaryJedis implements BinaryJedisCommands {
*
* Time complexity: O(1)
*
- * @see #incr(String)
- * @see #decr(String)
- * @see #decrBy(String, int)
+ * @see #incr(byte[])
+ * @see #decr(byte[])
+ * @see #decrBy(byte[], long)
*
* @param key
* @param integer
@@ -577,9 +603,9 @@ public class BinaryJedis implements BinaryJedisCommands {
* after the increment.
*/
public Long incrBy(final byte[] key, final long integer) {
- checkIsInMulti();
- client.incrBy(key, integer);
- return client.getIntegerReply();
+ checkIsInMulti();
+ client.incrBy(key, integer);
+ return client.getIntegerReply();
}
/**
@@ -596,18 +622,18 @@ public class BinaryJedis implements BinaryJedisCommands {
*
* Time complexity: O(1)
*
- * @see #incrBy(String, int)
- * @see #decr(String)
- * @see #decrBy(String, int)
+ * @see #incrBy(byte[], long)
+ * @see #decr(byte[])
+ * @see #decrBy(byte[], long)
*
* @param key
* @return Integer reply, this commands will reply with the new value of key
* after the increment.
*/
public Long incr(final byte[] key) {
- checkIsInMulti();
- client.incr(key);
- return client.getIntegerReply();
+ checkIsInMulti();
+ client.incr(key);
+ return client.getIntegerReply();
}
/**
@@ -627,9 +653,9 @@ public class BinaryJedis implements BinaryJedisCommands {
* the append operation.
*/
public Long append(final byte[] key, final byte[] value) {
- checkIsInMulti();
- client.append(key, value);
- return client.getIntegerReply();
+ checkIsInMulti();
+ client.append(key, value);
+ return client.getIntegerReply();
}
/**
@@ -651,9 +677,9 @@ public class BinaryJedis implements BinaryJedisCommands {
* @return Bulk reply
*/
public byte[] substr(final byte[] key, final int start, final int end) {
- checkIsInMulti();
- client.substr(key, start, end);
- return client.getBinaryBulkReply();
+ checkIsInMulti();
+ client.substr(key, start, end);
+ return client.getBinaryBulkReply();
}
/**
@@ -672,9 +698,9 @@ public class BinaryJedis implements BinaryJedisCommands {
* 1 is returned.
*/
public Long hset(final byte[] key, final byte[] field, final byte[] value) {
- checkIsInMulti();
- client.hset(key, field, value);
- return client.getIntegerReply();
+ checkIsInMulti();
+ client.hset(key, field, value);
+ return client.getIntegerReply();
}
/**
@@ -691,9 +717,9 @@ public class BinaryJedis implements BinaryJedisCommands {
* @return Bulk reply
*/
public byte[] hget(final byte[] key, final byte[] field) {
- checkIsInMulti();
- client.hget(key, field);
- return client.getBinaryBulkReply();
+ checkIsInMulti();
+ client.hget(key, field);
+ return client.getBinaryBulkReply();
}
/**
@@ -708,9 +734,9 @@ public class BinaryJedis implements BinaryJedisCommands {
* field is created 1 is returned.
*/
public Long hsetnx(final byte[] key, final byte[] field, final byte[] value) {
- checkIsInMulti();
- client.hsetnx(key, field, value);
- return client.getIntegerReply();
+ checkIsInMulti();
+ client.hsetnx(key, field, value);
+ return client.getIntegerReply();
}
/**
@@ -726,9 +752,9 @@ public class BinaryJedis implements BinaryJedisCommands {
* @return Always OK because HMSET can't fail
*/
public String hmset(final byte[] key, final Map hash) {
- checkIsInMulti();
- client.hmset(key, hash);
- return client.getStatusCodeReply();
+ checkIsInMulti();
+ client.hmset(key, hash);
+ return client.getStatusCodeReply();
}
/**
@@ -745,9 +771,9 @@ public class BinaryJedis implements BinaryJedisCommands {
* with the specified fields, in the same order of the request.
*/
public List hmget(final byte[] key, final byte[]... fields) {
- checkIsInMulti();
- client.hmget(key, fields);
- return client.getBinaryMultiBulkReply();
+ checkIsInMulti();
+ client.hmget(key, fields);
+ return client.getBinaryMultiBulkReply();
}
/**
@@ -769,9 +795,9 @@ public class BinaryJedis implements BinaryJedisCommands {
* operation.
*/
public Long hincrBy(final byte[] key, final byte[] field, final long value) {
- checkIsInMulti();
- client.hincrBy(key, field, value);
- return client.getIntegerReply();
+ checkIsInMulti();
+ client.hincrBy(key, field, value);
+ return client.getIntegerReply();
}
/**
@@ -785,9 +811,9 @@ public class BinaryJedis implements BinaryJedisCommands {
* Return 0 if the key is not found or the field is not present.
*/
public Boolean hexists(final byte[] key, final byte[] field) {
- checkIsInMulti();
- client.hexists(key, field);
- return client.getIntegerReply() == 1;
+ checkIsInMulti();
+ client.hexists(key, field);
+ return client.getIntegerReply() == 1;
}
/**
@@ -796,14 +822,14 @@ public class BinaryJedis implements BinaryJedisCommands {
* Time complexity: O(1)
*
* @param key
- * @param field
+ * @param fields
* @return If the field was present in the hash it is deleted and 1 is
* returned, otherwise 0 is returned and no operation is performed.
*/
- public Long hdel(final byte[] key, final byte[] field) {
- checkIsInMulti();
- client.hdel(key, field);
- return client.getIntegerReply();
+ public Long hdel(final byte[] key, final byte[]... fields) {
+ checkIsInMulti();
+ client.hdel(key, fields);
+ return client.getIntegerReply();
}
/**
@@ -817,9 +843,9 @@ public class BinaryJedis implements BinaryJedisCommands {
* an empty hash.
*/
public Long hlen(final byte[] key) {
- checkIsInMulti();
- client.hlen(key);
- return client.getIntegerReply();
+ checkIsInMulti();
+ client.hlen(key);
+ return client.getIntegerReply();
}
/**
@@ -831,10 +857,10 @@ public class BinaryJedis implements BinaryJedisCommands {
* @return All the fields names contained into a hash.
*/
public Set hkeys(final byte[] key) {
- checkIsInMulti();
- client.hkeys(key);
- final List lresult = client.getBinaryMultiBulkReply();
- return new HashSet(lresult);
+ checkIsInMulti();
+ client.hkeys(key);
+ final List lresult = client.getBinaryMultiBulkReply();
+ return new HashSet(lresult);
}
/**
@@ -846,10 +872,10 @@ public class BinaryJedis implements BinaryJedisCommands {
* @return All the fields values contained into a hash.
*/
public List hvals(final byte[] key) {
- checkIsInMulti();
- client.hvals(key);
- final List lresult = client.getBinaryMultiBulkReply();
- return lresult;
+ checkIsInMulti();
+ client.hvals(key);
+ final List lresult = client.getBinaryMultiBulkReply();
+ return lresult;
}
/**
@@ -861,16 +887,16 @@ public class BinaryJedis implements BinaryJedisCommands {
* @return All the fields and values contained into a hash.
*/
public Map hgetAll(final byte[] key) {
- checkIsInMulti();
- client.hgetAll(key);
- final List flatHash = client.getBinaryMultiBulkReply();
- final Map hash = new JedisByteHashMap();
- final Iterator iterator = flatHash.iterator();
- while (iterator.hasNext()) {
- hash.put(iterator.next(), iterator.next());
- }
+ checkIsInMulti();
+ client.hgetAll(key);
+ final List flatHash = client.getBinaryMultiBulkReply();
+ final Map hash = new JedisByteHashMap();
+ final Iterator iterator = flatHash.iterator();
+ while (iterator.hasNext()) {
+ hash.put(iterator.next(), iterator.next());
+ }
- return hash;
+ return hash;
}
/**
@@ -881,17 +907,17 @@ public class BinaryJedis implements BinaryJedisCommands {
*
* Time complexity: O(1)
*
- * @see BinaryJedis#lpush(String, String)
+ * @see BinaryJedis#rpush(byte[], byte[]...)
*
* @param key
- * @param string
+ * @param strings
* @return Integer reply, specifically, the number of elements inside the
* list after the push operation.
*/
- public Long rpush(final byte[] key, final byte[] string) {
- checkIsInMulti();
- client.rpush(key, string);
- return client.getIntegerReply();
+ public Long rpush(final byte[] key, final byte[]... strings) {
+ checkIsInMulti();
+ client.rpush(key, strings);
+ return client.getIntegerReply();
}
/**
@@ -902,17 +928,17 @@ public class BinaryJedis implements BinaryJedisCommands {
*
* Time complexity: O(1)
*
- * @see BinaryJedis#rpush(String, String)
+ * @see BinaryJedis#rpush(byte[], byte[]...)
*
* @param key
- * @param string
+ * @param strings
* @return Integer reply, specifically, the number of elements inside the
* list after the push operation.
*/
- public Long lpush(final byte[] key, final byte[] string) {
- checkIsInMulti();
- client.lpush(key, string);
- return client.getIntegerReply();
+ public Long lpush(final byte[] key, final byte[]... strings) {
+ checkIsInMulti();
+ client.lpush(key, strings);
+ return client.getIntegerReply();
}
/**
@@ -926,9 +952,9 @@ public class BinaryJedis implements BinaryJedisCommands {
* @return The length of the list.
*/
public Long llen(final byte[] key) {
- checkIsInMulti();
- client.llen(key);
- return client.getIntegerReply();
+ checkIsInMulti();
+ client.llen(key);
+ return client.getIntegerReply();
}
/**
@@ -969,10 +995,10 @@ public class BinaryJedis implements BinaryJedisCommands {
* @return Multi bulk reply, specifically a list of elements in the
* specified range.
*/
- public List lrange(final byte[] key, final int start, final int end) {
- checkIsInMulti();
- client.lrange(key, start, end);
- return client.getBinaryMultiBulkReply();
+ public List lrange(final byte[] key, final long start, final long end) {
+ checkIsInMulti();
+ client.lrange(key, start, end);
+ return client.getBinaryMultiBulkReply();
}
/**
@@ -1009,10 +1035,10 @@ public class BinaryJedis implements BinaryJedisCommands {
* @param end
* @return Status code reply
*/
- public String ltrim(final byte[] key, final int start, final int end) {
- checkIsInMulti();
- client.ltrim(key, start, end);
- return client.getStatusCodeReply();
+ public String ltrim(final byte[] key, final long start, final long end) {
+ checkIsInMulti();
+ client.ltrim(key, start, end);
+ return client.getStatusCodeReply();
}
/**
@@ -1033,10 +1059,10 @@ public class BinaryJedis implements BinaryJedisCommands {
* @param index
* @return Bulk reply, specifically the requested element
*/
- public byte[] lindex(final byte[] key, final int index) {
- checkIsInMulti();
- client.lindex(key, index);
- return client.getBinaryBulkReply();
+ public byte[] lindex(final byte[] key, final long index) {
+ checkIsInMulti();
+ client.lindex(key, index);
+ return client.getBinaryBulkReply();
}
/**
@@ -1053,17 +1079,17 @@ public class BinaryJedis implements BinaryJedisCommands {
* O(N) (with N being the length of the list), setting the first or last
* elements of the list is O(1).
*
- * @see #lindex(String, int)
+ * @see #lindex(byte[], int)
*
* @param key
* @param index
* @param value
* @return Status code reply
*/
- public String lset(final byte[] key, final int index, final byte[] value) {
- checkIsInMulti();
- client.lset(key, index, value);
- return client.getStatusCodeReply();
+ public String lset(final byte[] key, final long index, final byte[] value) {
+ checkIsInMulti();
+ client.lset(key, index, value);
+ return client.getStatusCodeReply();
}
/**
@@ -1071,7 +1097,7 @@ public class BinaryJedis implements BinaryJedisCommands {
* count is zero all the elements are removed. If count is negative elements
* are removed from tail to head, instead to go from head to tail that is
* the normal behaviour. So for example LREM with count -2 and hello as
- * value to remove against the list (a,b,c,hello,x,hello,hello) will lave
+ * value to remove against the list (a,b,c,hello,x,hello,hello) will have
* the list (a,b,c,hello,x). The number of removed elements is returned as
* an integer, see below for more information about the returned value. Note
* that non existing keys are considered like empty lists by LREM, so LREM
@@ -1085,10 +1111,10 @@ public class BinaryJedis implements BinaryJedisCommands {
* @return Integer Reply, specifically: The number of removed elements if
* the operation succeeded
*/
- public Long lrem(final byte[] key, final int count, final byte[] value) {
- checkIsInMulti();
- client.lrem(key, count, value);
- return client.getIntegerReply();
+ public Long lrem(final byte[] key, final long count, final byte[] value) {
+ checkIsInMulti();
+ client.lrem(key, count, value);
+ return client.getIntegerReply();
}
/**
@@ -1099,15 +1125,15 @@ public class BinaryJedis implements BinaryJedisCommands {
* If the key does not exist or the list is already empty the special value
* 'nil' is returned.
*
- * @see #rpop(String)
+ * @see #rpop(byte[])
*
* @param key
* @return Bulk reply
*/
public byte[] lpop(final byte[] key) {
- checkIsInMulti();
- client.lpop(key);
- return client.getBinaryBulkReply();
+ checkIsInMulti();
+ client.lpop(key);
+ return client.getBinaryBulkReply();
}
/**
@@ -1118,15 +1144,15 @@ public class BinaryJedis implements BinaryJedisCommands {
* If the key does not exist or the list is already empty the special value
* 'nil' is returned.
*
- * @see #lpop(String)
+ * @see #lpop(byte[])
*
* @param key
* @return Bulk reply
*/
public byte[] rpop(final byte[] key) {
- checkIsInMulti();
- client.rpop(key);
- return client.getBinaryBulkReply();
+ checkIsInMulti();
+ client.rpop(key);
+ return client.getBinaryBulkReply();
}
/**
@@ -1148,9 +1174,9 @@ public class BinaryJedis implements BinaryJedisCommands {
* @return Bulk reply
*/
public byte[] rpoplpush(final byte[] srckey, final byte[] dstkey) {
- checkIsInMulti();
- client.rpoplpush(srckey, dstkey);
- return client.getBinaryBulkReply();
+ checkIsInMulti();
+ client.rpoplpush(srckey, dstkey);
+ return client.getBinaryBulkReply();
}
/**
@@ -1162,14 +1188,14 @@ public class BinaryJedis implements BinaryJedisCommands {
* Time complexity O(1)
*
* @param key
- * @param member
+ * @param members
* @return Integer reply, specifically: 1 if the new element was added 0 if
* the element was already a member of the set
*/
- public Long sadd(final byte[] key, final byte[] member) {
- checkIsInMulti();
- client.sadd(key, member);
- return client.getIntegerReply();
+ public Long sadd(final byte[] key, final byte[]... members) {
+ checkIsInMulti();
+ client.sadd(key, members);
+ return client.getIntegerReply();
}
/**
@@ -1182,10 +1208,10 @@ public class BinaryJedis implements BinaryJedisCommands {
* @return Multi bulk reply
*/
public Set smembers(final byte[] key) {
- checkIsInMulti();
- client.smembers(key);
- final List members = client.getBinaryMultiBulkReply();
- return new HashSet(members);
+ checkIsInMulti();
+ client.smembers(key);
+ final List members = client.getBinaryMultiBulkReply();
+ return new HashSet(members);
}
/**
@@ -1200,17 +1226,17 @@ public class BinaryJedis implements BinaryJedisCommands {
* @return Integer reply, specifically: 1 if the new element was removed 0
* if the new element was not a member of the set
*/
- public Long srem(final byte[] key, final byte[] member) {
- checkIsInMulti();
- client.srem(key, member);
- return client.getIntegerReply();
+ public Long srem(final byte[] key, final byte[]... member) {
+ checkIsInMulti();
+ client.srem(key, member);
+ return client.getIntegerReply();
}
/**
* Remove a random element from a Set returning it as return value. If the
* Set is empty or the key does not exist, a nil object is returned.
*
- * The {@link #srandmember(String)} command does a similar work but the
+ * The {@link #srandmember(byte[])} command does a similar work but the
* returned element is not removed from the Set.
*
* Time complexity O(1)
@@ -1219,13 +1245,13 @@ public class BinaryJedis implements BinaryJedisCommands {
* @return Bulk reply
*/
public byte[] spop(final byte[] key) {
- checkIsInMulti();
- client.spop(key);
- return client.getBinaryBulkReply();
+ checkIsInMulti();
+ client.spop(key);
+ return client.getBinaryBulkReply();
}
/**
- * Move the specifided member from the set at srckey to the set at dstkey.
+ * Move the specified member from the set at srckey to the set at dstkey.
* This operation is atomic, in every given moment the element will appear
* to be in the source or destination set for accessing clients.
*
@@ -1248,10 +1274,10 @@ public class BinaryJedis implements BinaryJedisCommands {
* performed
*/
public Long smove(final byte[] srckey, final byte[] dstkey,
- final byte[] member) {
- checkIsInMulti();
- client.smove(srckey, dstkey, member);
- return client.getIntegerReply();
+ final byte[] member) {
+ checkIsInMulti();
+ client.smove(srckey, dstkey, member);
+ return client.getIntegerReply();
}
/**
@@ -1263,9 +1289,9 @@ public class BinaryJedis implements BinaryJedisCommands {
* of the set as an integer.
*/
public Long scard(final byte[] key) {
- checkIsInMulti();
- client.scard(key);
- return client.getIntegerReply();
+ checkIsInMulti();
+ client.scard(key);
+ return client.getIntegerReply();
}
/**
@@ -1281,18 +1307,18 @@ public class BinaryJedis implements BinaryJedisCommands {
* does not exist
*/
public Boolean sismember(final byte[] key, final byte[] member) {
- checkIsInMulti();
- client.sismember(key, member);
- return client.getIntegerReply() == 1;
+ checkIsInMulti();
+ client.sismember(key, member);
+ return client.getIntegerReply() == 1;
}
/**
* Return the members of a set resulting from the intersection of all the
* sets hold at the specified keys. Like in
- * {@link #lrange(String, int, int) LRANGE} the result is sent to the client
+ * {@link #lrange(byte[], int, int) LRANGE} the result is sent to the client
* as a multi-bulk reply (see the protocol specification for more
* information). If just a single key is specified, then this command
- * produces the same result as {@link #smembers(String) SMEMBERS}. Actually
+ * produces the same result as {@link #smembers(byte[]) SMEMBERS}. Actually
* SMEMBERS is just syntax sugar for SINTER.
*
* Non existing keys are considered like empty sets, so if one of the keys
@@ -1306,10 +1332,10 @@ public class BinaryJedis implements BinaryJedisCommands {
* @return Multi bulk reply, specifically the list of common elements.
*/
public Set sinter(final byte[]... keys) {
- checkIsInMulti();
- client.sinter(keys);
- final List members = client.getBinaryMultiBulkReply();
- return new HashSet(members);
+ checkIsInMulti();
+ client.sinter(keys);
+ final List members = client.getBinaryMultiBulkReply();
+ return new HashSet(members);
}
/**
@@ -1324,17 +1350,17 @@ public class BinaryJedis implements BinaryJedisCommands {
* @return Status code reply
*/
public Long sinterstore(final byte[] dstkey, final byte[]... keys) {
- checkIsInMulti();
- client.sinterstore(dstkey, keys);
- return client.getIntegerReply();
+ checkIsInMulti();
+ client.sinterstore(dstkey, keys);
+ return client.getIntegerReply();
}
/**
* Return the members of a set resulting from the union of all the sets hold
- * at the specified keys. Like in {@link #lrange(String, int, int) LRANGE}
+ * at the specified keys. Like in {@link #lrange(byte[], int, int) LRANGE}
* the result is sent to the client as a multi-bulk reply (see the protocol
* specification for more information). If just a single key is specified,
- * then this command produces the same result as {@link #smembers(String)
+ * then this command produces the same result as {@link #smembers(byte[])
* SMEMBERS}.
*
* Non existing keys are considered like empty sets.
@@ -1346,10 +1372,10 @@ public class BinaryJedis implements BinaryJedisCommands {
* @return Multi bulk reply, specifically the list of common elements.
*/
public Set sunion(final byte[]... keys) {
- checkIsInMulti();
- client.sunion(keys);
- final List members = client.getBinaryMultiBulkReply();
- return new HashSet(members);
+ checkIsInMulti();
+ client.sunion(keys);
+ final List members = client.getBinaryMultiBulkReply();
+ return new HashSet(members);
}
/**
@@ -1365,9 +1391,9 @@ public class BinaryJedis implements BinaryJedisCommands {
* @return Status code reply
*/
public Long sunionstore(final byte[] dstkey, final byte[]... keys) {
- checkIsInMulti();
- client.sunionstore(dstkey, keys);
- return client.getIntegerReply();
+ checkIsInMulti();
+ client.sunionstore(dstkey, keys);
+ return client.getIntegerReply();
}
/**
@@ -1394,10 +1420,10 @@ public class BinaryJedis implements BinaryJedisCommands {
* the first set provided and all the successive sets.
*/
public Set sdiff(final byte[]... keys) {
- checkIsInMulti();
- client.sdiff(keys);
- final List members = client.getBinaryMultiBulkReply();
- return new HashSet(members);
+ checkIsInMulti();
+ client.sdiff(keys);
+ final List members = client.getBinaryMultiBulkReply();
+ return new HashSet(members);
}
/**
@@ -1409,9 +1435,9 @@ public class BinaryJedis implements BinaryJedisCommands {
* @return Status code reply
*/
public Long sdiffstore(final byte[] dstkey, final byte[]... keys) {
- checkIsInMulti();
- client.sdiffstore(dstkey, keys);
- return client.getIntegerReply();
+ checkIsInMulti();
+ client.sdiffstore(dstkey, keys);
+ return client.getIntegerReply();
}
/**
@@ -1427,9 +1453,15 @@ public class BinaryJedis implements BinaryJedisCommands {
* @return Bulk reply
*/
public byte[] srandmember(final byte[] key) {
- checkIsInMulti();
- client.srandmember(key);
- return client.getBinaryBulkReply();
+ checkIsInMulti();
+ client.srandmember(key);
+ return client.getBinaryBulkReply();
+ }
+
+ public List srandmember(final byte[] key, final int count) {
+ checkIsInMulti();
+ client.srandmember(key, count);
+ return client.getBinaryMultiBulkReply();
}
/**
@@ -1454,16 +1486,22 @@ public class BinaryJedis implements BinaryJedisCommands {
* was updated
*/
public Long zadd(final byte[] key, final double score, final byte[] member) {
- checkIsInMulti();
- client.zadd(key, score, member);
- return client.getIntegerReply();
+ checkIsInMulti();
+ client.zadd(key, score, member);
+ return client.getIntegerReply();
}
- public Set zrange(final byte[] key, final int start, final int end) {
- checkIsInMulti();
- client.zrange(key, start, end);
- final List members = client.getBinaryMultiBulkReply();
- return new LinkedHashSet(members);
+ public Long zadd(final byte[] key, final Map scoreMembers) {
+ checkIsInMulti();
+ client.zaddBinary(key, scoreMembers);
+ return client.getIntegerReply();
+ }
+
+ public Set zrange(final byte[] key, final long start, final long end) {
+ checkIsInMulti();
+ client.zrange(key, start, end);
+ final List members = client.getBinaryMultiBulkReply();
+ return new LinkedHashSet(members);
}
/**
@@ -1477,14 +1515,14 @@ public class BinaryJedis implements BinaryJedisCommands {
*
*
* @param key
- * @param member
+ * @param members
* @return Integer reply, specifically: 1 if the new element was removed 0
* if the new element was not a member of the set
*/
- public Long zrem(final byte[] key, final byte[] member) {
- checkIsInMulti();
- client.zrem(key, member);
- return client.getIntegerReply();
+ public Long zrem(final byte[] key, final byte[]... members) {
+ checkIsInMulti();
+ client.zrem(key, members);
+ return client.getIntegerReply();
}
/**
@@ -1512,11 +1550,11 @@ public class BinaryJedis implements BinaryJedisCommands {
* @return The new score
*/
public Double zincrby(final byte[] key, final double score,
- final byte[] member) {
- checkIsInMulti();
- client.zincrby(key, score, member);
- String newscore = client.getBulkReply();
- return Double.valueOf(newscore);
+ final byte[] member) {
+ checkIsInMulti();
+ client.zincrby(key, score, member);
+ String newscore = client.getBulkReply();
+ return Double.valueOf(newscore);
}
/**
@@ -1531,7 +1569,7 @@ public class BinaryJedis implements BinaryJedisCommands {
*
* O(log(N))
*
- * @see #zrevrank(String, String)
+ * @see #zrevrank(byte[], byte[])
*
* @param key
* @param member
@@ -1540,9 +1578,9 @@ public class BinaryJedis implements BinaryJedisCommands {
* reply if there is no such element.
*/
public Long zrank(final byte[] key, final byte[] member) {
- checkIsInMulti();
- client.zrank(key, member);
- return client.getIntegerReply();
+ checkIsInMulti();
+ client.zrank(key, member);
+ return client.getIntegerReply();
}
/**
@@ -1557,7 +1595,7 @@ public class BinaryJedis implements BinaryJedisCommands {
*
* O(log(N))
*
- * @see #zrank(String, String)
+ * @see #zrank(byte[], byte[])
*
* @param key
* @param member
@@ -1566,33 +1604,33 @@ public class BinaryJedis implements BinaryJedisCommands {
* reply if there is no such element.
*/
public Long zrevrank(final byte[] key, final byte[] member) {
- checkIsInMulti();
- client.zrevrank(key, member);
- return client.getIntegerReply();
+ checkIsInMulti();
+ client.zrevrank(key, member);
+ return client.getIntegerReply();
}
- public Set zrevrange(final byte[] key, final int start,
- final int end) {
- checkIsInMulti();
- client.zrevrange(key, start, end);
- final List members = client.getBinaryMultiBulkReply();
- return new LinkedHashSet(members);
+ public Set zrevrange(final byte[] key, final long start,
+ final long end) {
+ checkIsInMulti();
+ client.zrevrange(key, start, end);
+ final List members = client.getBinaryMultiBulkReply();
+ return new LinkedHashSet(members);
}
- public Set zrangeWithScores(final byte[] key, final int start,
- final int end) {
- checkIsInMulti();
- client.zrangeWithScores(key, start, end);
- Set set = getBinaryTupledSet();
- return set;
+ public Set zrangeWithScores(final byte[] key, final long start,
+ final long end) {
+ checkIsInMulti();
+ client.zrangeWithScores(key, start, end);
+ Set set = getBinaryTupledSet();
+ return set;
}
- public Set zrevrangeWithScores(final byte[] key, final int start,
- final int end) {
- checkIsInMulti();
- client.zrevrangeWithScores(key, start, end);
- Set set = getBinaryTupledSet();
- return set;
+ public Set zrevrangeWithScores(final byte[] key, final long start,
+ final long end) {
+ checkIsInMulti();
+ client.zrevrangeWithScores(key, start, end);
+ Set set = getBinaryTupledSet();
+ return set;
}
/**
@@ -1605,9 +1643,9 @@ public class BinaryJedis implements BinaryJedisCommands {
* @return the cardinality (number of elements) of the set as an integer.
*/
public Long zcard(final byte[] key) {
- checkIsInMulti();
- client.zcard(key);
- return client.getIntegerReply();
+ checkIsInMulti();
+ client.zcard(key);
+ return client.getIntegerReply();
}
/**
@@ -1622,53 +1660,53 @@ public class BinaryJedis implements BinaryJedisCommands {
* @return the score
*/
public Double zscore(final byte[] key, final byte[] member) {
- checkIsInMulti();
- client.zscore(key, member);
- final String score = client.getBulkReply();
- return (score != null ? new Double(score) : null);
+ checkIsInMulti();
+ client.zscore(key, member);
+ final String score = client.getBulkReply();
+ return (score != null ? new Double(score) : null);
}
public Transaction multi() {
- client.multi();
- return new Transaction(client);
+ client.multi();
+ return new Transaction(client);
}
public List