Skip to content

Commit 042e083

Browse files
committed
Add new commands: psubscribe(), clearLastError(), small fix documentation
1 parent 7978e26 commit 042e083

File tree

1 file changed

+44
-8
lines changed

1 file changed

+44
-8
lines changed

src/redisphp.php

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,24 @@ public function unwatch( ) {}
344344
*/
345345
public function subscribe( $channels, $callback ) {}
346346

347+
/**
348+
* Subscribe to channels by pattern
349+
*
350+
* @param array $patterns The number of elements removed from the set.
351+
* @param string|array $callback Either a string or an array with an object and method.
352+
* The callback will get four arguments ($redis, $pattern, $channel, $message)
353+
* @link http://redis.io/commands/psubscribe
354+
* @example
355+
* <pre>
356+
* function psubscribe($redis, $pattern, $chan, $msg) {
357+
* echo "Pattern: $pattern\n";
358+
* echo "Channel: $chan\n";
359+
* echo "Payload: $msg\n";
360+
* }
361+
* </pre>
362+
*/
363+
public function psubscribe( $patterns, $callback ) {}
364+
347365
/**
348366
* Publish messages to channels. Warning: this function will probably change in the future.
349367
*
@@ -885,13 +903,14 @@ public function lInsert( $key, $position, $pivot, $value ) {}
885903

886904

887905
/**
888-
* Adds a values to the set value stored at key. If this value is already in the set, FALSE is returned.
906+
* Adds a values to the set value stored at key.
907+
* If this value is already in the set, FALSE is returned.
889908
*
890909
* @param string $key Required key
891910
* @param string $value1 Required value
892911
* @param string $value2 Optional value
893912
* @param string $valueN Optional value
894-
* @return int Number of value added
913+
* @return int The number of elements added to the set
895914
* @link http://redis.io/commands/sadd
896915
* @example
897916
* <pre>
@@ -909,7 +928,7 @@ public function sAdd( $key, $value1, $value2 = null, $valueN = null ) {}
909928
* @param string $member1
910929
* @param string $member2
911930
* @param string $memberN
912-
* @return int Number of deleted values
931+
* @return int The number of elements removed from the set.
913932
* @link http://redis.io/commands/srem
914933
* @example
915934
* <pre>
@@ -2376,8 +2395,8 @@ public function zIncrBy( $key, $value, $member ) {}
23762395
* $redis->zUnion('ko1', array('k1', 'k2')); // 4, 'ko1' => array('val0', 'val1', 'val2', 'val3')
23772396
*
23782397
* // Weighted zUnion
2379-
* $redis->zUnion('ko2', array('k1', 'k2'), array(1, 1)); // 4, 'ko1' => array('val0', 'val1', 'val2', 'val3')
2380-
* $redis->zUnion('ko3', array('k1', 'k2'), array(5, 1)); // 4, 'ko1' => array('val0', 'val2', 'val3', 'val1')
2398+
* $redis->zUnion('ko2', array('k1', 'k2'), array(1, 1)); // 4, 'ko2' => array('val0', 'val1', 'val2', 'val3')
2399+
* $redis->zUnion('ko3', array('k1', 'k2'), array(5, 1)); // 4, 'ko3' => array('val0', 'val2', 'val3', 'val1')
23812400
* </pre>
23822401
*/
23832402
public function zUnion($Output, $ZSetKeys, array $Weights = null, $aggregateFunction = 'SUM') {}
@@ -2774,7 +2793,7 @@ public function evalSha( $scriptSha, $args = array(), $numKeys = 0 ) {}
27742793
public function script( $command, $script ) {}
27752794

27762795
/**
2777-
* The last error message (if any) returned from a SCRIPT call
2796+
* The last error message (if any)
27782797
* @return string A string with the last returned script based error message, or NULL if there is no error
27792798
* @example
27802799
* <pre>
@@ -2785,13 +2804,30 @@ public function script( $command, $script ) {}
27852804
*/
27862805
public function getLastError() {}
27872806

2807+
/**
2808+
* Clear the last error message
2809+
*
2810+
* @return bool true
2811+
* @example
2812+
* <pre>
2813+
* $redis->set('x', 'a');
2814+
* $redis->incr('x');
2815+
* $err = $redis->getLastError();
2816+
* // "ERR value is not an integer or out of range"
2817+
* $redis->clearLastError();
2818+
* $err = $redis->getLastError();
2819+
* // NULL
2820+
* </pre>
2821+
*/
2822+
public function clearLastError() {}
2823+
27882824
/**
27892825
* A utility method to prefix the value with the prefix setting for phpredis.
27902826
* @param $value The value you wish to prefix
27912827
* @return string If a prefix is set up, the value now prefixed. If there is no prefix, the value will be returned unchanged.
27922828
* @example
27932829
* <pre>
2794-
* $redis->setOpt(Redis::OPT_PREFIX, 'my-prefix:');
2830+
* $redis->setOption(Redis::OPT_PREFIX, 'my-prefix:');
27952831
* $redis->_prefix('my-value'); // Will return 'my-prefix:my-value'
27962832
* </pre>
27972833
*/
@@ -2806,7 +2842,7 @@ public function _prefix( $value ) {}
28062842
* @return mixed
28072843
* @example
28082844
* <pre>
2809-
* $redis->setOpt(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);
2845+
* $redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);
28102846
* $redis->_unserialize('a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}'); // Will return Array(1,2,3)
28112847
* </pre>
28122848
*/

0 commit comments

Comments
 (0)