From 21ab1900df134cb80f7ce5faeea00d0dc1b1b956 Mon Sep 17 00:00:00 2001 From: Patrick Pokatilo Date: Thu, 9 Jul 2015 16:28:37 +0200 Subject: [PATCH 01/21] Add options READ_TIMEOUT, SCAN and SLAVE_FAILOVER --- src/Redis.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Redis.php b/src/Redis.php index afde25f..f514513 100644 --- a/src/Redis.php +++ b/src/Redis.php @@ -39,6 +39,22 @@ class Redis */ const OPT_SERIALIZER = 1; const OPT_PREFIX = 2; + const OPT_READ_TIMEOUT = 3; + const OPT_SCAN = 4; + const OPT_SLAVE_FAILOVER = 5; + + /** + * Cluster options + */ + const FAILOVER_NONE = 0; + const FAILOVER_ERROR = 1; + const FAILOVER_DISTRIBUTE = 2; + + /** + * SCAN options + */ + const SCAN_NORETRY = 0; + const SCAN_RETRY = 1; /** * Serializers From 7ad2f27ea9339478ec29d984a60215017c5dc746 Mon Sep 17 00:00:00 2001 From: Patrick Pokatilo Date: Thu, 9 Jul 2015 16:28:49 +0200 Subject: [PATCH 02/21] Add SCAN command --- src/Redis.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/Redis.php b/src/Redis.php index f514513..ba1307a 100644 --- a/src/Redis.php +++ b/src/Redis.php @@ -2961,6 +2961,25 @@ public function migrate( $host, $port, $key, $db, $timeout ) {} * */ public function time() {} + + /** + * Scan the keyspace for keys. + * @param int $iterator Iterator, initialized to NULL. + * @param string $pattern Pattern to match. + * @param int $count Count of keys per iteration (only a suggestion to Redis). + * @return array This function will return an array of keys or FALSE if there are no more keys. + * @link http://redis.io/commands/scan + * @example + *
+     * $iterator = null;
+     * while($keys = $redis->scan($iterator)) {
+     *     foreach($keys as $key) {
+     *         echo $key . PHP_EOL;
+     *     }
+     * }
+     * 
+ */ + public function scan( &$iterator, $pattern = null, $count = 0 ) {} } class RedisException extends Exception {} From dd63e7cf353d685608e3efe7cad62729267401cd Mon Sep 17 00:00:00 2001 From: Patrick Pokatilo Date: Thu, 9 Jul 2015 16:29:06 +0200 Subject: [PATCH 03/21] Update MIGRATE command --- src/Redis.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Redis.php b/src/Redis.php index ba1307a..ff6139b 100644 --- a/src/Redis.php +++ b/src/Redis.php @@ -2937,6 +2937,8 @@ public function restore( $key, $ttl, $value ) {} * @param string $key The key to migrate. * @param int $db The target DB. * @param int $timeout The maximum amount of time given to this transfer. + * @param bool $copy Should we send the COPY flag to redis. + * @param bool $replace Should we send the REPLACE flag to redis. * @return bool * @link http://redis.io/commands/migrate * @example @@ -2944,7 +2946,7 @@ public function restore( $key, $ttl, $value ) {} * $redis->migrate('backup', 6379, 'foo', 0, 3600); * */ - public function migrate( $host, $port, $key, $db, $timeout ) {} + public function migrate( $host, $port, $key, $db, $timeout, $copy = false, $replace = false ) {} /** * Return the current Redis server time. From 0620d83e0bf88d33b53ad38d0d9665406879e6c0 Mon Sep 17 00:00:00 2001 From: Patrick Pokatilo Date: Thu, 9 Jul 2015 16:35:56 +0200 Subject: [PATCH 04/21] Add HSCAN command --- src/Redis.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/Redis.php b/src/Redis.php index ff6139b..73d0ac8 100644 --- a/src/Redis.php +++ b/src/Redis.php @@ -2765,6 +2765,27 @@ public function hMset( $key, $hashKeys ) {} */ public function hMGet( $key, $hashKeys ) {} + /** + * Scan a HASH value for members, with an optional pattern and count. + * @param string $key + * @param int $iterator + * @param string $pattern Optional pattern to match against. + * @param int $count How many keys to return in a go (only a sugestion to Redis). + * @return array An array of members that match our pattern. + * @link http://redis.io/commands/hscan + * @example + *
+     * // $iterator = null;
+     * // while($elements = $redis->hscan('hash', $iterator)) {
+     * //     foreach($elements as $key => $value) {
+     * //         echo $key . ' => ' . $value . PHP_EOL;
+     * //     }
+     * // }
+     * 
+ */ + public function hScan( $key, &$iterator, $pattern = null, $count = 0 ) {} + + /** * Get or Set the redis config keys. * From 7ba0efd24d2c082e938d458fedf332f52a349ed2 Mon Sep 17 00:00:00 2001 From: Patrick Pokatilo Date: Thu, 9 Jul 2015 16:45:16 +0200 Subject: [PATCH 05/21] Add SSCAN command --- src/Redis.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Redis.php b/src/Redis.php index 73d0ac8..0f19a28 100644 --- a/src/Redis.php +++ b/src/Redis.php @@ -1335,6 +1335,26 @@ public function sMembers( $key ) {} */ public function sGetMembers( $key ) {} + /** + * Scan a set for members. + * @param string $key The set to search. + * @param int $iterator LONG (reference) to the iterator as we go. + * @param null $pattern String, optional pattern to match against. + * @param int $count How many members to return at a time (Redis might return a different amount). + * @return array PHPRedis will return an array of keys or FALSE when we're done iterating. + * @link http://redis.io/commands/sscan + * @example + *
+     * $iterator = null;
+     * while ($members = $redis->sscan('set', $iterator)) {
+     *     foreach ($members as $member) {
+     *         echo $member . PHP_EOL;
+     *     }
+     * }
+     * 
+ */ + public function sScan( $key, &$iterator, $pattern = null, $count = 0 ) {} + /** * Sets a value and returns the previous entry at that key. * From 892ce2646e12cb8942f247a3613201f85c8bbe7d Mon Sep 17 00:00:00 2001 From: Patrick Pokatilo Date: Thu, 9 Jul 2015 17:25:27 +0200 Subject: [PATCH 06/21] Add ZRANGEBYLEX command --- src/Redis.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/Redis.php b/src/Redis.php index 0f19a28..999c59e 100644 --- a/src/Redis.php +++ b/src/Redis.php @@ -2256,6 +2256,31 @@ public function zRangeByScore( $key, $start, $end, array $options = array() ) {} */ public function zRevRangeByScore( $key, $start, $end, array $options = array() ) {} + /** + * Returns a lexigraphical range of members in a sorted set, assuming the members have the same score. The + * min and max values are required to start with '(' (exclusive), '[' (inclusive), or be exactly the values + * '-' (negative inf) or '+' (positive inf). The command must be called with either three *or* five + * arguments or will return FALSE. + * @param string $key The ZSET you wish to run against. + * @param int $min The minimum alphanumeric value you wish to get. + * @param int $max The maximum alphanumeric value you wish to get. + * @param int $offset Optional argument if you wish to start somewhere other than the first element. + * @param int $limit Optional argument if you wish to limit the number of elements returned. + * @return array Array containing the values in the specified range. + * @link http://redis.io/commands/zrangebylex + * @example + *
+     * foreach (array('a', 'b', 'c', 'd', 'e', 'f', 'g') as $char) {
+     *     $redis->zAdd('key', $char);
+     * }
+     *
+     * $redis->zRangeByLex('key', '-', '[c'); // array('a', 'b', 'c')
+     * $redis->zRangeByLex('key', '-', '(c'); // array('a', 'b')
+     * $redis->zRangeByLex('key', '-', '[c'); // array('b', 'c')
+     * 
+ */ + public function zRangeByLex( $key, $min, $max, $offset = null, $limit = null ) {} + /** * Returns the number of elements of the sorted set stored at the specified key which have * scores in the range [start,end]. Adding a parenthesis before start or end excludes it From 1d089d0e5c05f51a4acea1022a6232237d0d2bdf Mon Sep 17 00:00:00 2001 From: Patrick Pokatilo Date: Thu, 9 Jul 2015 17:28:26 +0200 Subject: [PATCH 07/21] Add ZREVRANGEBYLEX command --- src/Redis.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Redis.php b/src/Redis.php index 999c59e..c1a6f87 100644 --- a/src/Redis.php +++ b/src/Redis.php @@ -2281,6 +2281,18 @@ public function zRevRangeByScore( $key, $start, $end, array $options = array() ) */ public function zRangeByLex( $key, $min, $max, $offset = null, $limit = null ) {} + /** + * @see zRangeByLex() + * @param string $key + * @param int $min + * @param int $max + * @param int $offset + * @param int $limit + * @return array + * @link http://redis.io/commands/zrevrangebylex + */ + public function zRevRangeByLex( $key, $min, $max, $offset = null, $limit = null ) {} + /** * Returns the number of elements of the sorted set stored at the specified key which have * scores in the range [start,end]. Adding a parenthesis before start or end excludes it From b9636c086ce378cbe68c91d61434ee1d10145e60 Mon Sep 17 00:00:00 2001 From: Patrick Pokatilo Date: Thu, 9 Jul 2015 17:33:26 +0200 Subject: [PATCH 08/21] Add ZSCAN command --- src/Redis.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Redis.php b/src/Redis.php index c1a6f87..c6d262a 100644 --- a/src/Redis.php +++ b/src/Redis.php @@ -2534,6 +2534,26 @@ public function zUnion($Output, $ZSetKeys, array $Weights = null, $aggregateFunc */ public function zInter($Output, $ZSetKeys, array $Weights = null, $aggregateFunction = 'SUM') {} + /** + * Scan a sorted set for members, with optional pattern and count. + * @param string $key String, the set to scan. + * @param int $iterator Long (reference), initialized to NULL. + * @param string $pattern String (optional), the pattern to match. + * @param int $count How many keys to return per iteration (Redis might return a different number). + * @return array PHPRedis will return matching keys from Redis, or FALSE when iteration is complete. + * @link http://redis.io/commands/zscan + * @example + *
+     * $iterator = null;
+     * while ($members = $redis-zscan('zset', $iterator)) {
+     *     foreach ($members as $member => $score) {
+     *         echo $member . ' => ' . $score . PHP_EOL;
+     *     }
+     * }
+     * 
+ */ + public function zScan( $key, &$iterator, $pattern = null, $count = 0 ) {} + /** * Adds a value to the hash stored at key. If this value is already in the hash, FALSE is returned. * From 257711ca5b067e379e7fd17c98ba61dfe2d5e273 Mon Sep 17 00:00:00 2001 From: Patrick Pokatilo Date: Thu, 9 Jul 2015 17:35:47 +0200 Subject: [PATCH 09/21] Update SUBSCRIBE and PSUBSCRIBE commands --- src/Redis.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Redis.php b/src/Redis.php index c6d262a..73512d3 100644 --- a/src/Redis.php +++ b/src/Redis.php @@ -337,6 +337,7 @@ public function unwatch( ) {} * @param array $channels an array of channels to subscribe to * @param string | array $callback either a string or an array($instance, 'method_name'). * The callback function receives 3 parameters: the redis instance, the channel name, and the message. + * @return mixed Any non-null return value in the callback will be returned to the caller. * @link http://redis.io/commands/subscribe * @example *
@@ -367,6 +368,7 @@ public function subscribe( $channels, $callback ) {}
      * @param   array           $patterns   The number of elements removed from the set.
      * @param   string|array    $callback   Either a string or an array with an object and method.
      *                          The callback will get four arguments ($redis, $pattern, $channel, $message)
+     * @param   mixed           Any non-null return value in the callback will be returned to the caller.
      * @link    http://redis.io/commands/psubscribe
      * @example
      * 

From d7a99fc075a04fdd15362a35a824593579ddb7b8 Mon Sep 17 00:00:00 2001
From: Patrick Pokatilo 
Date: Thu, 9 Jul 2015 17:43:39 +0200
Subject: [PATCH 10/21] Add PUBSUB command

---
 src/Redis.php | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/src/Redis.php b/src/Redis.php
index 73512d3..7a37367 100644
--- a/src/Redis.php
+++ b/src/Redis.php
@@ -392,6 +392,28 @@ public function psubscribe( $patterns, $callback ) {}
      */
     public function publish( $channel, $message ) {}
 
+    /**
+     * A command allowing you to get information on the Redis pub/sub system.
+     * @param   string          $keyword    String, which can be: "channels", "numsub", or "numpat"
+     * @param   string|array    $argument   Optional, variant.
+     *                                      For the "channels" subcommand, you can pass a string pattern.
+     *                                      For "numsub" an array of channel names
+     * @return  array|int                   Either an integer or an array.
+     *                          - channels  Returns an array where the members are the matching channels.
+     *                          - numsub    Returns a key/value array where the keys are channel names and
+     *                                      values are their counts.
+     *                          - numpat    Integer return containing the number active pattern subscriptions.
+     * @link    http://redis.io/commands/pubsub
+     * @example
+     * 
+     * $redis->pubsub('channels'); // All channels
+     * $redis->pubsub('channels', '*pattern*'); // Just channels matching your pattern
+     * $redis->pubsub('numsub', array('chan1', 'chan2')); // Get subscriber counts for 'chan1' and 'chan2'
+     * $redis->pubsub('numpat'); // Get the number of pattern subscribers
+     * 
+ */ + public function pubsub( $keyword, $argument ) {} + /** * Verify if the specified key exists. * From 08c5ab7dc8d82bb2f49b79ba185d63bd670b71f5 Mon Sep 17 00:00:00 2001 From: Patrick Pokatilo Date: Thu, 9 Jul 2015 17:47:21 +0200 Subject: [PATCH 11/21] Add utility method _serialize() --- src/Redis.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Redis.php b/src/Redis.php index 7a37367..18e443e 100644 --- a/src/Redis.php +++ b/src/Redis.php @@ -3020,6 +3020,26 @@ public function _prefix( $value ) {} */ public function _unserialize( $value ) {} + /** + * A utility method to serialize values manually. This method allows you to serialize a value with whatever + * serializer is configured, manually. This can be useful for serialization/unserialization of data going in + * and out of EVAL commands as phpredis can't automatically do this itself. Note that if no serializer is + * set, phpredis will change Array values to 'Array', and Objects to 'Object'. + * @param mixed $value The value to be serialized. + * @return mixed + * @example + *
+     * $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_NONE);
+     * $redis->_serialize("foo"); // returns "foo"
+     * $redis->_serialize(Array()); // Returns "Array"
+     * $redis->_serialize(new stdClass()); // Returns "Object"
+     *
+     * $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);
+     * $redis->_serialize("foo"); // Returns 's:3:"foo";'
+     * 
+ */ + public function _serialize( $value ) {} + /** * Dump a key out of a redis database, the value of which can later be passed into redis using the RESTORE command. * The data that comes out of DUMP is a binary representation of the key as Redis stores it. From ff87523e61f172e0374ccf8cfe7fd5a865c64d25 Mon Sep 17 00:00:00 2001 From: Patrick Pokatilo Date: Thu, 9 Jul 2015 17:56:34 +0200 Subject: [PATCH 12/21] Add WAIT command --- src/Redis.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Redis.php b/src/Redis.php index 18e443e..a81b41d 100644 --- a/src/Redis.php +++ b/src/Redis.php @@ -1687,6 +1687,17 @@ public function bgsave( ) {} */ public function lastSave( ) {} + /** + * Blocks the current client until all the previous write commands are successfully transferred and + * acknowledged by at least the specified number of slaves. + * @param int $numSlaves Number of slaves that need to acknowledge previous write commands. + * @param int $timeout Timeout in milliseconds. + * @return int The command returns the number of slaves reached by all the writes performed in the + * context of the current connection. + * @link http://redis.io/commands/wait + * @example $redis->wait(2, 1000); + */ + public function wait( $numSlaves, $timeout ) {} /** * Returns the type of data pointed by a given key. From 233563241659a8d6f0cedbe6b084c117b6117fef Mon Sep 17 00:00:00 2001 From: Patrick Pokatilo Date: Thu, 9 Jul 2015 18:15:33 +0200 Subject: [PATCH 13/21] Add PFADD command --- src/Redis.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Redis.php b/src/Redis.php index a81b41d..3eae479 100644 --- a/src/Redis.php +++ b/src/Redis.php @@ -3135,6 +3135,16 @@ public function time() {} *
*/ public function scan( &$iterator, $pattern = null, $count = 0 ) {} + + /** + * Adds all the element arguments to the HyperLogLog data structure stored at the key. + * @param string $key + * @param array $elements + * @return bool + * @link http://redis.io/commands/pfadd + * @example $redis->pfAdd('key', array('elem1', 'elem2')) + */ + public function pfAdd( $key, array $elements ) {} } class RedisException extends Exception {} From c85336562c2a878e3c59f0182608ab45523abfc7 Mon Sep 17 00:00:00 2001 From: Patrick Pokatilo Date: Thu, 9 Jul 2015 18:15:50 +0200 Subject: [PATCH 14/21] Add PFCOUNT command --- src/Redis.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Redis.php b/src/Redis.php index 3eae479..87e1750 100644 --- a/src/Redis.php +++ b/src/Redis.php @@ -3145,6 +3145,21 @@ public function scan( &$iterator, $pattern = null, $count = 0 ) {} * @example $redis->pfAdd('key', array('elem1', 'elem2')) */ public function pfAdd( $key, array $elements ) {} + + /** + * When called with a single key, returns the approximated cardinality computed by the HyperLogLog data + * structure stored at the specified variable, which is 0 if the variable does not exist. + * @param string|array $key + * @return int + * @link http://redis.io/commands/pfcount + * @example + *
+     * $redis->pfAdd('key1', array('elem1', 'elem2'));
+     * $redis->pfAdd('key2', array('elem3', 'elem2'));
+     * $redis->pfCount('key1'); // int(2)
+     * $redis->pfCount(array('key1', 'key2')); // int(3)
+     */
+    public function pfCount( $key ) {}
 }
 
 class RedisException extends Exception {}

From ff55c8b0efb2ea48b8410dba63ca14af88d5bd22 Mon Sep 17 00:00:00 2001
From: Patrick Pokatilo 
Date: Thu, 9 Jul 2015 18:16:00 +0200
Subject: [PATCH 15/21] Add PFMERGE command

---
 src/Redis.php | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/Redis.php b/src/Redis.php
index 87e1750..4d2ad4b 100644
--- a/src/Redis.php
+++ b/src/Redis.php
@@ -3160,6 +3160,22 @@ public function pfAdd( $key, array $elements ) {}
      * $redis->pfCount(array('key1', 'key2')); // int(3)
      */
     public function pfCount( $key ) {}
+
+    /**
+     * Merge multiple HyperLogLog values into an unique value that will approximate the cardinality
+     * of the union of the observed Sets of the source HyperLogLog structures.
+     * @param   string  $destkey
+     * @param   array   $sourcekeys
+     * @return  bool
+     * @link    http://redis.io/commands/pfmerge
+     * @example
+     * 
+     * $redis->pfAdd('key1', array('elem1', 'elem2'));
+     * $redis->pfAdd('key2', array('elem3', 'elem2'));
+     * $redis->pfMerge('key3', array('key1', 'key2'));
+     * $redis->pfCount('key3'); // int(3)
+     */
+    public function pfMerge( $destkey, array $sourcekeys ) {}
 }
 
 class RedisException extends Exception {}

From 6bfe57113ca0cb33ee85e62d42c5a1a43bb7ddcf Mon Sep 17 00:00:00 2001
From: Patrick Pokatilo 
Date: Thu, 9 Jul 2015 18:25:50 +0200
Subject: [PATCH 16/21] Add rawCommand

---
 src/Redis.php | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/Redis.php b/src/Redis.php
index 4d2ad4b..b829611 100644
--- a/src/Redis.php
+++ b/src/Redis.php
@@ -3176,6 +3176,19 @@ public function pfCount( $key ) {}
      * $redis->pfCount('key3'); // int(3)
      */
     public function pfMerge( $destkey, array $sourcekeys ) {}
+
+    /**
+     * Send arbitrary things to the redis server.
+     * @param   string      $command    Required command to send to the server.
+     * @param   mixed,...   $arguments  Optional variable amount of arguments to send to the server.
+     * @return  mixed
+     * @example
+     * 
+     * $redis->rawCommand('SET', 'key', 'value'); // bool(true)
+     * $redis->rawCommand('GET", 'key'); // string(5) "value"
+     * 
+ */ + public function rawCommand( $command, $arguments ) {} } class RedisException extends Exception {} From db594da4a17e284fd0c816c882d898382a16975b Mon Sep 17 00:00:00 2001 From: Patrick Pokatilo Date: Thu, 9 Jul 2015 18:29:00 +0200 Subject: [PATCH 17/21] Update constants AFTER and BEFORE --- src/Redis.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Redis.php b/src/Redis.php index b829611..9496280 100644 --- a/src/Redis.php +++ b/src/Redis.php @@ -31,8 +31,8 @@ */ class Redis { - const AFTER = ''; - const BEFORE = ''; + const AFTER = 'after'; + const BEFORE = 'before'; /** * Options From 79b5b6980d31aa9e984375102dbd469be5dfc79e Mon Sep 17 00:00:00 2001 From: Patrick Pokatilo Date: Thu, 9 Jul 2015 18:29:16 +0200 Subject: [PATCH 18/21] Update constants ATOMIC, MULTI and PIPELINE --- src/Redis.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Redis.php b/src/Redis.php index 9496280..dba0720 100644 --- a/src/Redis.php +++ b/src/Redis.php @@ -66,8 +66,9 @@ class Redis /** * Multi */ - const MULTI = ''; - const PIPELINE = ''; + const ATOMIC = 0; + const MULTI = 1; + const PIPELINE = 2; /** * Type From 0d9f56c0a99fdbe31a235353af90920e7517eabf Mon Sep 17 00:00:00 2001 From: Patrick Pokatilo Date: Thu, 9 Jul 2015 19:23:02 +0200 Subject: [PATCH 19/21] Add BITPOS command --- src/Redis.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/Redis.php b/src/Redis.php index dba0720..9672e39 100644 --- a/src/Redis.php +++ b/src/Redis.php @@ -1795,6 +1795,38 @@ public function setRange( $key, $offset, $value ) {} */ public function strlen( $key ) {} + /** + * Return the position of the first bit set to 1 or 0 in a string. The position is returned, thinking of the + * string as an array of bits from left to right, where the first byte's most significant bit is at position 0, + * the second byte's most significant bit is at position 8, and so forth. + * @param string $key + * @param int $bit + * @param int $start + * @param int $end + * @return int The command returns the position of the first bit set to 1 or 0 according to the request. + * If we look for set bits (the bit argument is 1) and the string is empty or composed of just + * zero bytes, -1 is returned. If we look for clear bits (the bit argument is 0) and the string + * only contains bit set to 1, the function returns the first bit not part of the string on the + * right. So if the string is three bytes set to the value 0xff the command BITPOS key 0 will + * return 24, since up to bit 23 all the bits are 1. Basically, the function considers the right + * of the string as padded with zeros if you look for clear bits and specify no range or the + * start argument only. However, this behavior changes if you are looking for clear bits and + * specify a range with both start and end. If no clear bit is found in the specified range, the + * function returns -1 as the user specified a clear range and there are no 0 bits in that range. + * @link http://redis.io/commands/bitpos + * @example + *
+     * $redis->set('key', '\xff\xff');
+     * $redis->bitpos('key', 1); // int(0)
+     * $redis->bitpos('key', 1, 1); // int(8)
+     * $redis->bitpos('key', 1, 3); // int(-1)
+     * $redis->bitpos('key', 0); // int(16)
+     * $redis->bitpos('key', 0, 1); // int(16)
+     * $redis->bitpos('key', 0, 1, 5); // int(-1)
+     * 
+ */ + public function bitpos( $key, $bit, $start = 0, $end = null) {} + /** * Return a single bit out of a larger string * From fcaf713b84f1f51a82b1e231b5fc99d0db94fece Mon Sep 17 00:00:00 2001 From: Patrick Pokatilo Date: Thu, 9 Jul 2015 19:27:32 +0200 Subject: [PATCH 20/21] Add getMode --- src/Redis.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Redis.php b/src/Redis.php index 9672e39..21b0ff6 100644 --- a/src/Redis.php +++ b/src/Redis.php @@ -3222,6 +3222,13 @@ public function pfMerge( $destkey, array $sourcekeys ) {} *
*/ public function rawCommand( $command, $arguments ) {} + + /** + * Detect whether we're in ATOMIC/MULTI/PIPELINE mode. + * @return int Either Redis::ATOMIC, Redis::MULTI or Redis::PIPELINE + * @example $redis->getMode(); + */ + public function getMode() {} } class RedisException extends Exception {} From fd8a47fabb6462a6dd52713e504792f31d2b234c Mon Sep 17 00:00:00 2001 From: Patrick Pokatilo Date: Mon, 20 Jul 2015 00:28:30 +0200 Subject: [PATCH 21/21] Change case of method name in example --- src/Redis.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Redis.php b/src/Redis.php index 21b0ff6..f224ed1 100644 --- a/src/Redis.php +++ b/src/Redis.php @@ -1371,7 +1371,7 @@ public function sGetMembers( $key ) {} * @example *
      * $iterator = null;
-     * while ($members = $redis->sscan('set', $iterator)) {
+     * while ($members = $redis->sScan('set', $iterator)) {
      *     foreach ($members as $member) {
      *         echo $member . PHP_EOL;
      *     }