mget(String... keys) {
+ checkIsInMulti();
+ client.mget(keys);
+ return client.getMultiBulkReply();
+ }
+
+ /**
+ * SETNX works exactly like {@link #set(String, String) SET} with the only
+ * difference that if the key already exists no operation is performed.
+ * SETNX actually means "SET if Not eXists".
+ *
+ * Time complexity: O(1)
+ *
+ * @param key
+ * @param value
+ * @return Integer reply, specifically: 1 if the key was set 0 if the key
+ * was not set
+ */
+ public Integer setnx(String key, String value) {
+ 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}.
+ * The operation is atomic.
+ *
+ * Time complexity: O(1)
+ *
+ * @param key
+ * @param seconds
+ * @param value
+ * @return Status code reply
+ */
+ public String setex(String key, int seconds, String value) {
+ checkIsInMulti();
+ client.setex(key, seconds, value);
+ return client.getStatusCodeReply();
+ }
+
+ /**
+ * Set the the respective keys to the respective values. MSET will replace
+ * old values with new values, while {@link #msetnx(String...) MSETNX} will
+ * not perform any operation at all even if just a single key already
+ * exists.
+ *
+ * Because of this semantic MSETNX can be used in order to set different
+ * keys representing different fields of an unique logic object in a way
+ * that ensures that either all the fields or none at all are set.
+ *
+ * Both MSET and MSETNX are atomic operations. This means that for instance
+ * if the keys A and B are modified, another client talking to Redis can
+ * either see the changes to both A and B at once, or no modification at
+ * all.
+ *
+ * @see #msetnx(String...)
+ *
+ * @param keysvalues
+ * @return Status code reply Basically +OK as MSET can't fail
+ */
+ public String mset(String... keysvalues) {
+ checkIsInMulti();
+ client.mset(keysvalues);
+ return client.getStatusCodeReply();
+ }
+
+ /**
+ * Set the the respective keys to the respective values.
+ * {@link #mset(String...) MSET} will replace old values with new values,
+ * while MSETNX will not perform any operation at all even if just a single
+ * key already exists.
+ *
+ * Because of this semantic MSETNX can be used in order to set different
+ * keys representing different fields of an unique logic object in a way
+ * that ensures that either all the fields or none at all are set.
+ *
+ * Both MSET and MSETNX are atomic operations. This means that for instance
+ * if the keys A and B are modified, another client talking to Redis can
+ * either see the changes to both A and B at once, or no modification at
+ * all.
+ *
+ * @see #mset(String...)
+ *
+ * @param keysvalues
+ * @return Integer reply, specifically: 1 if the all the keys were set 0 if
+ * no key was set (at least one key already existed)
+ */
+ public Integer msetnx(String... keysvalues) {
+ checkIsInMulti();
+ client.msetnx(keysvalues);
+ return client.getIntegerReply();
+ }
+
+ /**
+ * IDECRBY work just like {@link #decr(String) INCR} but instead to
+ * decrement by 1 the decrement is integer.
+ *
+ * INCR commands are limited to 64 bit signed integers.
+ *
+ * Note: this is actually a string operation, that is, in Redis there are
+ * not "integer" types. Simply the string stored at the key is parsed as a
+ * base 10 64 bit signed integer, incremented, and then converted back as a
+ * string.
+ *
+ * Time complexity: O(1)
+ *
+ * @see #incr(String)
+ * @see #decr(String)
+ * @see #incrBy(String, int)
+ *
+ * @param key
+ * @param integer
+ * @return Integer reply, this commands will reply with the new value of key
+ * after the increment.
+ */
+ public Integer decrBy(String key, int integer) {
+ checkIsInMulti();
+ client.decrBy(key, integer);
+ return client.getIntegerReply();
+ }
+
+ /**
+ * Decrement the number stored at key by one. If the key does not exist or
+ * contains a value of a wrong type, set the key to the value of "0" before
+ * to perform the decrement operation.
+ *
+ * INCR commands are limited to 64 bit signed integers.
+ *
+ * Note: this is actually a string operation, that is, in Redis there are
+ * not "integer" types. Simply the string stored at the key is parsed as a
+ * base 10 64 bit signed integer, incremented, and then converted back as a
+ * string.
+ *
+ * Time complexity: O(1)
+ *
+ * @see #incr(String)
+ * @see #incrBy(String, int)
+ * @see #decrBy(String, int)
+ *
+ * @param key
+ * @return Integer reply, this commands will reply with the new value of key
+ * after the increment.
+ */
+ public Integer decr(String key) {
+ checkIsInMulti();
+ client.decr(key);
+ return client.getIntegerReply();
+ }
+
+ /**
+ * INCRBY work just like {@link #incr(String) INCR} but instead to increment
+ * by 1 the increment is integer.
+ *
+ * INCR commands are limited to 64 bit signed integers.
+ *
+ * Note: this is actually a string operation, that is, in Redis there are
+ * not "integer" types. Simply the string stored at the key is parsed as a
+ * base 10 64 bit signed integer, incremented, and then converted back as a
+ * string.
+ *
+ * Time complexity: O(1)
+ *
+ * @see #incr(String)
+ * @see #decr(String)
+ * @see #decrBy(String, int)
+ *
+ * @param key
+ * @param integer
+ * @return Integer reply, this commands will reply with the new value of key
+ * after the increment.
+ */
+ public Integer incrBy(String key, int integer) {
+ checkIsInMulti();
+ client.incrBy(key, integer);
+ return client.getIntegerReply();
+ }
+
+ /**
+ * Increment the number stored at key by one. If the key does not exist or
+ * contains a value of a wrong type, set the key to the value of "0" before
+ * to perform the increment operation.
+ *
+ * INCR commands are limited to 64 bit signed integers.
+ *
+ * Note: this is actually a string operation, that is, in Redis there are
+ * not "integer" types. Simply the string stored at the key is parsed as a
+ * base 10 64 bit signed integer, incremented, and then converted back as a
+ * string.
+ *
+ * Time complexity: O(1)
+ *
+ * @see #incrBy(String, int)
+ * @see #decr(String)
+ * @see #decrBy(String, int)
+ *
+ * @param key
+ * @return Integer reply, this commands will reply with the new value of key
+ * after the increment.
+ */
+ public Integer incr(String key) {
+ checkIsInMulti();
+ client.incr(key);
+ return client.getIntegerReply();
+ }
+
+ /**
+ * If the key already exists and is a string, this command appends the
+ * provided value at the end of the string. If the key does not exist it is
+ * created and set as an empty string, so APPEND will be very similar to SET
+ * in this special case.
+ *
+ * Time complexity: O(1). The amortized time complexity is O(1) assuming the
+ * appended value is small and the already present value is of any size,
+ * since the dynamic string library used by Redis will double the free space
+ * available on every reallocation.
+ *
+ * @param key
+ * @param value
+ * @return Integer reply, specifically the total length of the string after
+ * the append operation.
+ */
+ public Integer append(String key, String value) {
+ checkIsInMulti();
+ client.append(key, value);
+ return client.getIntegerReply();
+ }
+
+ /**
+ * Return a subset of the string from offset start to offset end (both
+ * offsets are inclusive). Negative offsets can be used in order to provide
+ * an offset starting from the end of the string. So -1 means the last char,
+ * -2 the penultimate and so forth.
+ *
+ * The function handles out of range requests without raising an error, but
+ * just limiting the resulting range to the actual length of the string.
+ *
+ * Time complexity: O(start+n) (with start being the start index and n the
+ * total length of the requested range). Note that the lookup part of this
+ * command is O(1) so for small strings this is actually an O(1) command.
+ *
+ * @param key
+ * @param start
+ * @param end
+ * @return Bulk reply
+ */
+ public String substr(String key, int start, int end) {
+ checkIsInMulti();
+ client.substr(key, start, end);
+ return client.getBulkReply();
+ }
+
+ /**
+ *
+ * Set the specified hash field to the specified value.
+ *
+ * If key does not exist, a new key holding a hash is created.
+ *
+ * Time complexity: O(1)
+ *
+ * @param key
+ * @param field
+ * @param value
+ * @return If the field already exists, and the HSET just produced an update
+ * of the value, 0 is returned, otherwise if a new field is created
+ * 1 is returned.
+ */
+ public Integer hset(String key, String field, String value) {
+ checkIsInMulti();
+ client.hset(key, field, value);
+ return client.getIntegerReply();
+ }
+
+ /**
+ * If key holds a hash, retrieve the value associated to the specified
+ * field.
+ *
+ * If the field is not found or the key does not exist, a special 'nil'
+ * value is returned.
+ *
+ * Time complexity: O(1)
+ *
+ * @param key
+ * @param field
+ * @return Bulk reply
+ */
+ public String hget(String key, String field) {
+ checkIsInMulti();
+ client.hget(key, field);
+ return client.getBulkReply();
+ }
+
+ /**
+ *
+ * Set the specified hash field to the specified value if the field not
+ * exists. Time complexity: O(1)
+ *
+ * @param key
+ * @param field
+ * @param value
+ * @return If the field already exists, 0 is returned, otherwise if a new
+ * field is created 1 is returned.
+ */
+ public Integer hsetnx(String key, String field, String value) {
+ checkIsInMulti();
+ client.hsetnx(key, field, value);
+ return client.getIntegerReply();
+ }
+
+ /**
+ * Set the respective fields to the respective values. HMSET replaces old
+ * values with new values.
+ *
+ * If key does not exist, a new key holding a hash is created.
+ *
+ * Time complexity: O(N) (with N being the number of fields)
+ *
+ * @param key
+ * @param hash
+ * @return Always OK because HMSET can't fail
+ */
+ public String hmset(String key, Map hash) {
+ checkIsInMulti();
+ client.hmset(key, hash);
+ return client.getStatusCodeReply();
+ }
+
+ /**
+ * Retrieve the values associated to the specified fields.
+ *
+ * If some of the specified fields do not exist, nil values are returned.
+ * Non existing keys are considered like empty hashes.
+ *
+ * Time complexity: O(N) (with N being the number of fields)
+ *
+ * @param key
+ * @param fields
+ * @return Multi Bulk Reply specifically a list of all the values associated
+ * with the specified fields, in the same order of the request.
+ */
+ public List hmget(String key, String... fields) {
+ checkIsInMulti();
+ client.hmget(key, fields);
+ return client.getMultiBulkReply();
+ }
+
+ /**
+ * Increment the number stored at field in the hash at key by value. If key
+ * does not exist, a new key holding a hash is created. If field does not
+ * exist or holds a string, the value is set to 0 before applying the
+ * operation. Since the value argument is signed you can use this command to
+ * perform both increments and decrements.
+ *
+ * The range of values supported by HINCRBY is limited to 64 bit signed
+ * integers.
+ *
+ * Time complexity: O(1)
+ *
+ * @param key
+ * @param field
+ * @param value
+ * @return Integer reply The new value at field after the increment
+ * operation.
+ */
+ public Integer hincrBy(String key, String field, int value) {
+ checkIsInMulti();
+ client.hincrBy(key, field, value);
+ return client.getIntegerReply();
+ }
+
+ /**
+ * Test for existence of a specified field in a hash.
+ *
+ * Time complexity: O(1)
+ *
+ * @param key
+ * @param field
+ * @return Return 1 if the hash stored at key contains the specified field.
+ * Return 0 if the key is not found or the field is not present.
+ */
+ public Integer hexists(String key, String field) {
+ checkIsInMulti();
+ client.hexists(key, field);
+ return client.getIntegerReply();
+ }
+
+ /**
+ * Remove the specified field from an hash stored at key.
+ *
+ * Time complexity: O(1)
+ *
+ * @param key
+ * @param field
+ * @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 Integer hdel(String key, String field) {
+ checkIsInMulti();
+ client.hdel(key, field);
+ return client.getIntegerReply();
+ }
+
+ /**
+ * Return the number of items in a hash.
+ *
+ * Time complexity: O(1)
+ *
+ * @param key
+ * @return The number of entries (fields) contained in the hash stored at
+ * key. If the specified key does not exist, 0 is returned assuming
+ * an empty hash.
+ */
+ public Integer hlen(String key) {
+ checkIsInMulti();
+ client.hlen(key);
+ return client.getIntegerReply();
+ }
+
+ /**
+ * Return all the fields in a hash.
+ *
+ * Time complexity: O(N), where N is the total number of entries
+ *
+ * @param key
+ * @return All the fields names contained into a hash.
+ */
+ public List hkeys(String key) {
+ checkIsInMulti();
+ client.hkeys(key);
+ return client.getMultiBulkReply();
+ }
+
+ /**
+ * Return all the values in a hash.
+ *
+ * Time complexity: O(N), where N is the total number of entries
+ *
+ * @param key
+ * @return All the fields values contained into a hash.
+ */
+ public List hvals(String key) {
+ checkIsInMulti();
+ client.hvals(key);
+ return client.getMultiBulkReply();
+ }
+
+ /**
+ * Return all the fields and associated values in a hash.
+ *
+ * Time complexity: O(N), where N is the total number of entries
+ *
+ * @param key
+ * @return All the fields and values contained into a hash.
+ */
+ public Map hgetAll(String key) {
+ checkIsInMulti();
+ client.hgetAll(key);
+ List flatHash = client.getMultiBulkReply();
+ Map hash = new HashMap();
+ Iterator iterator = flatHash.iterator();
+ while (iterator.hasNext()) {
+ hash.put(iterator.next(), iterator.next());
+ }
+
+ return hash;
+ }
+
+ /**
+ * Add the string value to the head (LPUSH) or tail (RPUSH) of the list
+ * stored at key. If the key does not exist an empty list is created just
+ * before the append operation. If the key exists but is not a List an error
+ * is returned.
+ *
+ * Time complexity: O(1)
+ *
+ * @see Jedis#lpush(String, String)
+ *
+ * @param key
+ * @param string
+ * @return Integer reply, specifically, the number of elements inside the
+ * list after the push operation.
+ */
+ public Integer rpush(String key, String string) {
+ checkIsInMulti();
+ client.rpush(key, string);
+ return client.getIntegerReply();
+ }
+
+ /**
+ * Add the string value to the head (LPUSH) or tail (RPUSH) of the list
+ * stored at key. If the key does not exist an empty list is created just
+ * before the append operation. If the key exists but is not a List an error
+ * is returned.
+ *
+ * Time complexity: O(1)
+ *
+ * @see Jedis#rpush(String, String)
+ *
+ * @param key
+ * @param string
+ * @return Integer reply, specifically, the number of elements inside the
+ * list after the push operation.
+ */
+ public Integer lpush(String key, String string) {
+ checkIsInMulti();
+ client.lpush(key, string);
+ return client.getIntegerReply();
+ }
+
+ /**
+ * Return the length of the list stored at the specified key. If the key
+ * does not exist zero is returned (the same behaviour as for empty lists).
+ * If the value stored at key is not a list an error is returned.
+ *
+ * Time complexity: O(1)
+ *
+ * @param key
+ * @return The length of the list.
+ */
+ public Integer llen(String key) {
+ checkIsInMulti();
+ client.llen(key);
+ return client.getIntegerReply();
+ }
+
+ /**
+ * Return the specified elements of the list stored at the specified key.
+ * Start and end are zero-based indexes. 0 is the first element of the list
+ * (the list head), 1 the next element and so on.
+ *
+ * For example LRANGE foobar 0 2 will return the first three elements of the
+ * list.
+ *
+ * start and end can also be negative numbers indicating offsets from the
+ * end of the list. For example -1 is the last element of the list, -2 the
+ * penultimate element and so on.
+ *
+ * Consistency with range functions in various programming languages
+ *
+ * Note that if you have a list of numbers from 0 to 100, LRANGE 0 10 will
+ * return 11 elements, that is, rightmost item is included. This may or may
+ * not be consistent with behavior of range-related functions in your
+ * programming language of choice (think Ruby's Range.new, Array#slice or
+ * Python's range() function).
+ *
+ * LRANGE behavior is consistent with one of Tcl.
+ *
+ * Out-of-range indexes
+ *
+ * Indexes out of range will not produce an error: if start is over the end
+ * of the list, or start > end, an empty list is returned. If end is over
+ * the end of the list Redis will threat it just like the last element of
+ * the list.
+ *
+ * Time complexity: O(start+n) (with n being the length of the range and
+ * start being the start offset)
+ *
+ * @param key
+ * @param start
+ * @param end
+ * @return Multi bulk reply, specifically a list of elements in the
+ * specified range.
+ */
+ public List lrange(String key, int start, int end) {
+ checkIsInMulti();
+ client.lrange(key, start, end);
+ return client.getMultiBulkReply();
+ }
+
+ /**
+ * Trim an existing list so that it will contain only the specified range of
+ * elements specified. Start and end are zero-based indexes. 0 is the first
+ * element of the list (the list head), 1 the next element and so on.
+ *
+ * For example LTRIM foobar 0 2 will modify the list stored at foobar key so
+ * that only the first three elements of the list will remain.
+ *
+ * start and end can also be negative numbers indicating offsets from the
+ * end of the list. For example -1 is the last element of the list, -2 the
+ * penultimate element and so on.
+ *
+ * Indexes out of range will not produce an error: if start is over the end
+ * of the list, or start > end, an empty list is left as value. If end over
+ * the end of the list Redis will threat it just like the last element of
+ * the list.
+ *
+ * Hint: the obvious use of LTRIM is together with LPUSH/RPUSH. For example:
+ *
+ * {@code
+ * lpush("mylist", "someelement");
+ * ltrim("mylist", 0, 99);
+ * }
+ *
+ * The above two commands will push elements in the list taking care that
+ * the list will not grow without limits. This is very useful when using
+ * Redis to store logs for example. It is important to note that when used
+ * in this way LTRIM is an O(1) operation because in the average case just
+ * one element is removed from the tail of the list.
+ *
+ * Time complexity: O(n) (with n being len of list - len of range)
+ *
+ * @param key
+ * @param start
+ * @param end
+ * @return Status code reply
+ */
+ public String ltrim(String key, int start, int end) {
+ checkIsInMulti();
+ client.ltrim(key, start, end);
+ return client.getStatusCodeReply();
+ }
+
+ /**
+ * Return the specified element of the list stored at the specified key. 0
+ * is the first element, 1 the second and so on. Negative indexes are
+ * supported, for example -1 is the last element, -2 the penultimate and so
+ * on.
+ *
+ * If the value stored at key is not of list type an error is returned. If
+ * the index is out of range a 'nil' reply is returned.
+ *
+ * Note that even if the average time complexity is O(n) asking for the
+ * first or the last element of the list is O(1).
+ *
+ * Time complexity: O(n) (with n being the length of the list)
+ *
+ * @param key
+ * @param index
+ * @return Bulk reply, specifically the requested element
+ */
+ public String lindex(String key, int index) {
+ checkIsInMulti();
+ client.lindex(key, index);
+ return client.getBulkReply();
+ }
+
+ /**
+ * Set a new value as the element at index position of the List at key.
+ *
+ * Out of range indexes will generate an error.
+ *
+ * Similarly to other list commands accepting indexes, the index can be
+ * negative to access elements starting from the end of the list. So -1 is
+ * the last element, -2 is the penultimate, and so forth.
+ *
+ * Time complexity:
+ *
+ * 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)
+ *
+ * @param key
+ * @param index
+ * @param value
+ * @return Status code reply
+ */
+ public String lset(String key, int index, String value) {
+ checkIsInMulti();
+ client.lset(key, index, value);
+ return client.getStatusCodeReply();
+ }
+
+ /**
+ * Remove the first count occurrences of the value element from the list. If
+ * 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
+ * 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
+ * against non existing keys will always return 0.
+ *
+ * Time complexity: O(N) (with N being the length of the list)
+ *
+ * @param key
+ * @param count
+ * @param value
+ * @return Integer Reply, specifically: The number of removed elements if
+ * the operation succeeded
+ */
+ public Integer lrem(String key, int count, String value) {
+ checkIsInMulti();
+ client.lrem(key, count, value);
+ return client.getIntegerReply();
+ }
+
+ /**
+ * Atomically return and remove the first (LPOP) or last (RPOP) element of
+ * the list. For example if the list contains the elements "a","b","c" LPOP
+ * will return "a" and the list will become "b","c".
+ *
+ * If the key does not exist or the list is already empty the special value
+ * 'nil' is returned.
+ *
+ * @see #rpop(String)
+ *
+ * @param key
+ * @return Bulk reply
+ */
+ public String lpop(String key) {
+ checkIsInMulti();
+ client.lpop(key);
+ return client.getBulkReply();
+ }
+
+ /**
+ * Atomically return and remove the first (LPOP) or last (RPOP) element of
+ * the list. For example if the list contains the elements "a","b","c" LPOP
+ * will return "a" and the list will become "b","c".
+ *
+ * If the key does not exist or the list is already empty the special value
+ * 'nil' is returned.
+ *
+ * @see #lpop(String)
+ *
+ * @param key
+ * @return Bulk reply
+ */
+ public String rpop(String key) {
+ checkIsInMulti();
+ client.rpop(key);
+ return client.getBulkReply();
+ }
+
+ /**
+ * Atomically return and remove the last (tail) element of the srckey list,
+ * and push the element as the first (head) element of the dstkey list. For
+ * example if the source list contains the elements "a","b","c" and the
+ * destination list contains the elements "foo","bar" after an RPOPLPUSH
+ * command the content of the two lists will be "a","b" and "c","foo","bar".
+ *
+ * If the key does not exist or the list is already empty the special value
+ * 'nil' is returned. If the srckey and dstkey are the same the operation is
+ * equivalent to removing the last element from the list and pusing it as
+ * first element of the list, so it's a "list rotation" command.
+ *
+ * Time complexity: O(1)
+ *
+ * @param srckey
+ * @param dstkey
+ * @return Bulk reply
+ */
+ public String rpoplpush(String srckey, String dstkey) {
+ checkIsInMulti();
+ client.rpoplpush(srckey, dstkey);
+ return client.getBulkReply();
+ }
+
+ /**
+ * Add the specified member to the set value stored at key. If member is
+ * already a member of the set no operation is performed. If key does not
+ * exist a new set with the specified member as sole member is created. If
+ * the key exists but does not hold a set value an error is returned.
+ *
+ * Time complexity O(1)
+ *
+ * @param key
+ * @param member
+ * @return Integer reply, specifically: 1 if the new element was added 0 if
+ * the element was already a member of the set
+ */
+ public Integer sadd(String key, String member) {
+ checkIsInMulti();
+ client.sadd(key, member);
+ return client.getIntegerReply();
+ }
+
+ /**
+ * Return all the members (elements) of the set value stored at key. This is
+ * just syntax glue for {@link #sinter(String...) SINTER}.
+ *
+ * Time complexity O(N)
+ *
+ * @param key
+ * @return Multi bulk reply
+ */
+ public Set smembers(String key) {
+ checkIsInMulti();
+ client.smembers(key);
+ List members = client.getMultiBulkReply();
+ return new LinkedHashSet(members);
+ }
+
+ /**
+ * Remove the specified member from the set value stored at key. If member
+ * was not a member of the set no operation is performed. If key does not
+ * hold a set value an error is returned.
+ *
+ * Time complexity O(1)
+ *
+ * @param key
+ * @param member
+ * @return Integer reply, specifically: 1 if the new element was removed 0
+ * if the new element was not a member of the set
+ */
+ public Integer srem(String key, String 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
+ * returned element is not removed from the Set.
+ *
+ * Time complexity O(1)
+ *
+ * @param key
+ * @return Bulk reply
+ */
+ public String spop(String key) {
+ checkIsInMulti();
+ client.spop(key);
+ return client.getBulkReply();
+ }
+
+ /**
+ * Move the specifided 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.
+ *
+ * If the source set does not exist or does not contain the specified
+ * element no operation is performed and zero is returned, otherwise the
+ * element is removed from the source set and added to the destination set.
+ * On success one is returned, even if the element was already present in
+ * the destination set.
+ *
+ * An error is raised if the source or destination keys contain a non Set
+ * value.
+ *
+ * Time complexity O(1)
+ *
+ * @param srckey
+ * @param dstkey
+ * @param member
+ * @return Integer reply, specifically: 1 if the element was moved 0 if the
+ * element was not found on the first set and no operation was
+ * performed
+ */
+ public Integer smove(String srckey, String dstkey, String member) {
+ checkIsInMulti();
+ client.smove(srckey, dstkey, member);
+ return client.getIntegerReply();
+ }
+
+ /**
+ * Return the set cardinality (number of elements). If the key does not
+ * exist 0 is returned, like for empty sets.
+ *
+ * @param key
+ * @return Integer reply, specifically: the cardinality (number of elements)
+ * of the set as an integer.
+ */
+ public Integer scard(String key) {
+ checkIsInMulti();
+ client.scard(key);
+ return client.getIntegerReply();
+ }
+
+ /**
+ * Return 1 if member is a member of the set stored at key, otherwise 0 is
+ * returned.
+ *
+ * Time complexity O(1)
+ *
+ * @param key
+ * @param member
+ * @return Integer reply, specifically: 1 if the element is a member of the
+ * set 0 if the element is not a member of the set OR if the key
+ * does not exist
+ */
+ public Integer sismember(String key, String member) {
+ checkIsInMulti();
+ client.sismember(key, member);
+ return client.getIntegerReply();
+ }
+
+ /**
+ * 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
+ * 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
+ * SMEMBERS is just syntax sugar for SINTER.
+ *
+ * Non existing keys are considered like empty sets, so if one of the keys
+ * is missing an empty set is returned (since the intersection with an empty
+ * set always is an empty set).
+ *
+ * Time complexity O(N*M) worst case where N is the cardinality of the
+ * smallest set and M the number of sets
+ *
+ * @param keys
+ * @return Multi bulk reply, specifically the list of common elements.
+ */
+ public Set sinter(String... keys) {
+ checkIsInMulti();
+ client.sinter(keys);
+ List members = client.getMultiBulkReply();
+ return new LinkedHashSet(members);
+ }
+
+ /**
+ * This commnad works exactly like {@link #sinter(String...) SINTER} but
+ * instead of being returned the resulting set is sotred as dstkey.
+ *
+ * Time complexity O(N*M) worst case where N is the cardinality of the
+ * smallest set and M the number of sets
+ *
+ * @param dstkey
+ * @param keys
+ * @return Status code reply
+ */
+ public Integer sinterstore(String dstkey, String... keys) {
+ 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}
+ * 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}.
+ *
+ * Non existing keys are considered like empty sets.
+ *
+ * Time complexity O(N) where N is the total number of elements in all the
+ * provided sets
+ *
+ * @param keys
+ * @return Multi bulk reply, specifically the list of common elements.
+ */
+ public Set sunion(String... keys) {
+ checkIsInMulti();
+ client.sunion(keys);
+ List members = client.getMultiBulkReply();
+ return new LinkedHashSet(members);
+ }
+
+ /**
+ * This command works exactly like {@link #sunion(String...) SUNION} but
+ * instead of being returned the resulting set is stored as dstkey. Any
+ * existing value in dstkey will be over-written.
+ *
+ * Time complexity O(N) where N is the total number of elements in all the
+ * provided sets
+ *
+ * @param dstkey
+ * @param keys
+ * @return Status code reply
+ */
+ public Integer sunionstore(String dstkey, String... keys) {
+ checkIsInMulti();
+ client.sunionstore(dstkey, keys);
+ return client.getIntegerReply();
+ }
+
+ /**
+ * Return the difference between the Set stored at key1 and all the Sets
+ * key2, ..., keyN
+ *
+ * Example:
+ *
+ *
+ * key1 = [x, a, b, c]
+ * key2 = [c]
+ * key3 = [a, d]
+ * SDIFF key1,key2,key3 => [x, b]
+ *
+ *
+ * Non existing keys are considered like empty sets.
+ *
+ * Time complexity:
+ *
+ * O(N) with N being the total number of elements of all the sets
+ *
+ * @param keys
+ * @return Return the members of a set resulting from the difference between
+ * the first set provided and all the successive sets.
+ */
+ public Set sdiff(String... keys) {
+ checkIsInMulti();
+ client.sdiff(keys);
+ List members = client.getMultiBulkReply();
+ return new LinkedHashSet(members);
+ }
+
+ /**
+ * This command works exactly like {@link #sdiff(String...) SDIFF} but
+ * instead of being returned the resulting set is stored in dstkey.
+ *
+ * @param dstkey
+ * @param keys
+ * @return Status code reply
+ */
+ public Integer sdiffstore(String dstkey, String... keys) {
+ checkIsInMulti();
+ client.sdiffstore(dstkey, keys);
+ return client.getIntegerReply();
+ }
+
+ /**
+ * Return a random element from a Set, without removing the element. If the
+ * Set is empty or the key does not exist, a nil object is returned.
+ *
+ * The SPOP command does a similar work but the returned element is popped
+ * (removed) from the Set.
+ *
+ * Time complexity O(1)
+ *
+ * @param key
+ * @return Bulk reply
+ */
+ public String srandmember(String key) {
+ checkIsInMulti();
+ client.srandmember(key);
+ return client.getBulkReply();
+ }
+
+ /**
+ * Add the specified member having the specifeid score to the sorted set
+ * stored at key. If member is already a member of the sorted set the score
+ * is updated, and the element reinserted in the right position to ensure
+ * sorting. If key does not exist a new sorted set with the specified member
+ * as sole member is crated. If the key exists but does not hold a sorted
+ * set value an error is returned.
+ *
+ * The score value can be the string representation of a double precision
+ * floating point number.
+ *
+ * Time complexity O(log(N)) with N being the number of elements in the
+ * sorted set
+ *
+ * @param key
+ * @param score
+ * @param member
+ * @return Integer reply, specifically: 1 if the new element was added 0 if
+ * the element was already a member of the sorted set and the score
+ * was updated
+ */
+ public Integer zadd(String key, double score, String member) {
+ checkIsInMulti();
+ client.zadd(key, score, member);
+ return client.getIntegerReply();
+ }
+
+ public Set zrange(String key, int start, int end) {
+ checkIsInMulti();
+ client.zrange(key, start, end);
+ List members = client.getMultiBulkReply();
+ return new LinkedHashSet(members);
+ }
+
+ /**
+ * Remove the specified member from the sorted set value stored at key. If
+ * member was not a member of the set no operation is performed. If key does
+ * not not hold a set value an error is returned.
+ *
+ * Time complexity O(log(N)) with N being the number of elements in the
+ * sorted set
+ *
+ *
+ *
+ * @param key
+ * @param member
+ * @return Integer reply, specifically: 1 if the new element was removed 0
+ * if the new element was not a member of the set
+ */
+ public Integer zrem(String key, String member) {
+ checkIsInMulti();
+ client.zrem(key, member);
+ return client.getIntegerReply();
+ }
+
+ /**
+ * If member already exists in the sorted set adds the increment to its
+ * score and updates the position of the element in the sorted set
+ * accordingly. If member does not already exist in the sorted set it is
+ * added with increment as score (that is, like if the previous score was
+ * virtually zero). If key does not exist a new sorted set with the
+ * specified member as sole member is crated. If the key exists but does not
+ * hold a sorted set value an error is returned.
+ *
+ * The score value can be the string representation of a double precision
+ * floating point number. It's possible to provide a negative value to
+ * perform a decrement.
+ *
+ * For an introduction to sorted sets check the Introduction to Redis data
+ * types page.
+ *
+ * Time complexity O(log(N)) with N being the number of elements in the
+ * sorted set
+ *
+ * @param key
+ * @param score
+ * @param member
+ * @return The new score
+ */
+ public Double zincrby(String key, double score, String member) {
+ checkIsInMulti();
+ client.zincrby(key, score, member);
+ String newscore = client.getBulkReply();
+ return Double.valueOf(newscore);
+ }
+
+ /**
+ * Return the rank (or index) or member in the sorted set at key, with
+ * scores being ordered from low to high.
+ *
+ * When the given member does not exist in the sorted set, the special value
+ * 'nil' is returned. The returned rank (or index) of the member is 0-based
+ * for both commands.
+ *
+ * Time complexity:
+ *
+ * O(log(N))
+ *
+ * @see #zrevrank(String, String)
+ *
+ * @param key
+ * @param member
+ * @return Integer reply or a nil bulk reply, specifically: the rank of the
+ * element as an integer reply if the element exists. A nil bulk
+ * reply if there is no such element.
+ */
+ public Integer zrank(String key, String member) {
+ checkIsInMulti();
+ client.zrank(key, member);
+ return client.getIntegerReply();
+ }
+
+ /**
+ * Return the rank (or index) or member in the sorted set at key, with
+ * scores being ordered from high to low.
+ *
+ * When the given member does not exist in the sorted set, the special value
+ * 'nil' is returned. The returned rank (or index) of the member is 0-based
+ * for both commands.
+ *
+ * Time complexity:
+ *
+ * O(log(N))
+ *
+ * @see #zrank(String, String)
+ *
+ * @param key
+ * @param member
+ * @return Integer reply or a nil bulk reply, specifically: the rank of the
+ * element as an integer reply if the element exists. A nil bulk
+ * reply if there is no such element.
+ */
+ public Integer zrevrank(String key, String member) {
+ checkIsInMulti();
+ client.zrevrank(key, member);
+ return client.getIntegerReply();
+ }
+
+ public Set zrevrange(String key, int start, int end) {
+ checkIsInMulti();
+ client.zrevrange(key, start, end);
+ List members = client.getMultiBulkReply();
+ return new LinkedHashSet(members);
+ }
+
+ public Set zrangeWithScores(String key, int start, int end) {
+ checkIsInMulti();
+ client.zrangeWithScores(key, start, end);
+ Set set = getTupledSet();
+ return set;
+ }
+
+ public Set zrevrangeWithScores(String key, int start, int end) {
+ checkIsInMulti();
+ client.zrevrangeWithScores(key, start, end);
+ Set set = getTupledSet();
+ return set;
+ }
+
+ /**
+ * Return the sorted set cardinality (number of elements). If the key does
+ * not exist 0 is returned, like for empty sorted sets.
+ *
+ * Time complexity O(1)
+ *
+ * @param key
+ * @return the cardinality (number of elements) of the set as an integer.
+ */
+ public Integer zcard(String key) {
+ checkIsInMulti();
+ client.zcard(key);
+ return client.getIntegerReply();
+ }
+
+ /**
+ * Return the score of the specified element of the sorted set at key. If
+ * the specified element does not exist in the sorted set, or the key does
+ * not exist at all, a special 'nil' value is returned.
+ *
+ * Time complexity: O(1)
+ *
+ * @param key
+ * @param member
+ * @return the score
+ */
+ public Double zscore(String key, String member) {
+ checkIsInMulti();
+ client.zscore(key, member);
+ String score = client.getBulkReply();
+ return (score != null ? new Double(score) : null);
+ }
+
+ public Transaction multi() {
+ client.multi();
+ client.getStatusCodeReply();
+ return new Transaction(client);
+ }
+
+ public List