Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit df50b2a

Browse files
Documentation: More complete command docblocks
APPEND clearLastError DBSIZE DECR[BY] DEL [skip ci]
1 parent e8f5b51 commit df50b2a

6 files changed

Lines changed: 162 additions & 6 deletions

redis.stub.php

Lines changed: 139 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,26 @@ public function _unpack(string $value): mixed;
150150

151151
public function acl(string $subcmd, string ...$args): mixed;
152152

153+
/**
154+
* Append data to a Redis STRING key.
155+
*
156+
* @param string $key The key in question
157+
* @param mixed $value The data to append to the key.
158+
*
159+
* @return Redis|int|false The new string length of the key or false on failure.
160+
*
161+
* <code>
162+
* <?php
163+
* $redis = new Redis(['host' => 'localhost']);
164+
*
165+
* $redis->set('foo', 'hello);
166+
* var_dump($redis->append('foo', 'world'));
167+
*
168+
* // --- OUTPUT ---
169+
* // int(10)
170+
* ?>
171+
* </code>
172+
*/
153173
public function append(string $key, mixed $value): Redis|int|false;
154174

155175
/**
@@ -391,6 +411,22 @@ public function lmpop(array $keys, string $from, int $count = 1): Redis|array|nu
391411
*
392412
* @return bool This should always return true or throw an exception if we're not connected.
393413
*
414+
* <code>
415+
* <?php
416+
* $redis = new Redis(['host' => 'localhost']);
417+
*
418+
* $redis->set('string', 'this_is_a_string');
419+
* $redis->smembers('string');
420+
*
421+
* var_dump($redis->getLastError());
422+
* $redis->clearLastError();
423+
* var_dump($redis->getLastError());
424+
*
425+
* // --- OUTPUT ---
426+
* // string(65) "WRONGTYPE Operation against a key holding the wrong kind of value"
427+
* // NULL
428+
* ?>
429+
* </code>
394430
*/
395431
public function clearLastError(): bool;
396432

@@ -428,14 +464,116 @@ public function connect(string $host, int $port = 6379, float $timeout = 0, stri
428464

429465
public function copy(string $src, string $dst, array $options = null): Redis|bool;
430466

431-
public function dbSize(): Redis|int;
467+
/**
468+
* Return the number of keys in the currently selected Redis database.
469+
*
470+
* @see https://redis.io/commands/dbsize
471+
*
472+
* @return Redis|int The number of keys or false on failure.
473+
*
474+
* <code>
475+
* <?php
476+
* $redis = new Redis(['host' => 'localhost']);
477+
*
478+
* $redis->flushdb();
479+
*
480+
* $redis->set('foo', 'bar');
481+
* var_dump($redis->dbsize());
482+
*
483+
* $redis->mset(['a' => 'a', 'b' => 'b', 'c' => 'c', 'd' => 'd']);
484+
* var_dump($redis->dbsize());
485+
*
486+
* // --- OUTPUT
487+
* // int(1)
488+
* // int(5)
489+
* ?>
490+
*/
491+
public function dbSize(): Redis|int|false;
432492

433493
public function debug(string $key): Redis|string;
434494

495+
/**
496+
* Decrement a Redis integer by 1 or a provided value.
497+
*
498+
* @param string $key The key to decrement
499+
* @param int $by How much to decrement the key. Note that if this value is
500+
* not sent or is set to `1`, PhpRedis will actually invoke
501+
* the 'DECR' command. If it is any value other than `1`
502+
* PhpRedis will actually send the `DECRBY` command.
503+
*
504+
* @return Redis|int|false The new value of the key or false on failure.
505+
*
506+
* <code>
507+
* <?php
508+
* $redis = new Redis(['host' => 'localhost']);
509+
*
510+
* $redis->set('counter', 3);
511+
*
512+
* var_dump($redis->decr('counter'));
513+
* var_dump($redis->decr('counter', 2));
514+
*
515+
* // --- OUTPUT ---
516+
* // int(2)
517+
* // int(0)
518+
* ?>
519+
* </code>
520+
*/
435521
public function decr(string $key, int $by = 1): Redis|int|false;
436522

523+
/**
524+
* Decrement a redis integer by a value
525+
*
526+
* @param string $key The integer key to decrement.
527+
* @param int $value How much to decrement the key.
528+
*
529+
* @return Redis|int|false The new value of the key or false on failure.
530+
*
531+
* <code>
532+
* <?php
533+
* $redis = new Redis(['host' => 'localhost');
534+
*
535+
* $redis->set('counter', 3);
536+
* var_dump($redis->decrby('counter', 1));
537+
* var_dump($redis->decrby('counter', 2));
538+
*
539+
* // --- OUTPUT ---
540+
* // int(2)
541+
* // int(0)
542+
* ?>
543+
* </code>
544+
*/
437545
public function decrBy(string $key, int $value): Redis|int|false;
438546

547+
/**
548+
* Delete one or more keys from Redis.
549+
*
550+
* @see https://redis.io/commands/del
551+
*
552+
* @param array|string $key_or_keys Either an array with one or more key names or a string with
553+
* the name of a key.
554+
* @param string $other_keys One or more additional keys passed in a variadic fashion.
555+
*
556+
* This method can be called in two distinct ways. The first is to pass a single array
557+
* of keys to delete, and the second is to pass N arguments, all names of keys. See
558+
* below for an example of both strategies.
559+
*
560+
* <code>
561+
* <?php
562+
* $redis = new Redis(['host' => 'localhost']);
563+
*
564+
* for ($i = 0; $i < 5; $i++) {
565+
* $redis->set("key:$i", "val:$i");
566+
* }
567+
*
568+
* var_dump($redis->del('key:0', 'key:1'));
569+
* var_dump($redis->del(['key:2', 'key:3', 'key:4']));
570+
*
571+
* // --- OUTPUT ---
572+
* // int(2)
573+
* // int(3)
574+
* ?>
575+
* </code>
576+
*/
439577
public function del(array|string $key, string ...$other_keys): Redis|int|false;
440578

441579
/**

redis_arginfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: dbcafdb797bd3a4a656d0e1708715bba10ed7f94 */
2+
* Stub hash: d9cbe3fdc3c4cd1b079427a54ff2b24ac1c21adc */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis___construct, 0, 0, 0)
55
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 0, "null")
@@ -147,7 +147,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_copy, 0, 2, Redi
147147
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 0, "null")
148148
ZEND_END_ARG_INFO()
149149

150-
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_dbSize, 0, 0, Redis, MAY_BE_LONG)
150+
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_dbSize, 0, 0, Redis, MAY_BE_LONG|MAY_BE_FALSE)
151151
ZEND_END_ARG_INFO()
152152

153153
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_debug, 0, 1, Redis, MAY_BE_STRING)

redis_cluster.stub.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ public function _redir(): string|null;
5151

5252
public function acl(string|array $key_or_address, string $subcmd, string ...$args): mixed;
5353

54+
/**
55+
* @see Redis::append()
56+
*/
5457
public function append(string $key, mixed $value): RedisCluster|bool|int;
5558

5659
public function bgrewriteaof(string|array $key_or_address): RedisCluster|bool;
@@ -108,6 +111,9 @@ public function blmpop(float $timeout, array $keys, string $from, int $count = 1
108111
*/
109112
public function lmpop(array $keys, string $from, int $count = 1): RedisCluster|array|null|false;
110113

114+
/**
115+
* @see Redis::clearlasterror()
116+
*/
111117
public function clearlasterror(): bool;
112118

113119
public function client(string|array $key_or_address, string $subcommand, ?string $arg = NULL): array|string|bool;
@@ -120,14 +126,26 @@ public function command(mixed ...$extra_args): mixed;
120126

121127
public function config(string|array $key_or_address, string $subcommand, mixed ...$extra_args): mixed;
122128

129+
/**
130+
* @see Redis::dbsize()
131+
*/
123132
public function dbsize(string|array $key_or_address): RedisCluster|int;
124133

134+
/**
135+
* @see Redis::decr()
136+
*/
125137
public function decr(string $key, int $by = 1): RedisCluster|int|false;
126138

139+
/**
140+
* @see Redis::decrby()
141+
*/
127142
public function decrby(string $key, int $value): RedisCluster|int|false;
128143

129144
public function decrbyfloat(string $key, float $value): float;
130145

146+
/**
147+
* @see Redis::del()
148+
*/
131149
public function del(array|string $key, string ...$other_keys): RedisCluster|int|false;
132150

133151
public function discard(): bool;

redis_cluster_arginfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: cb1fe939ac54b2c0e5de0c354fc4a6118336de61 */
2+
* Stub hash: fb0623f92a600a7b3cba70d9f3ba82164914f267 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster___construct, 0, 0, 1)
55
ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 1)

redis_cluster_legacy_arginfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: cb1fe939ac54b2c0e5de0c354fc4a6118336de61 */
2+
* Stub hash: fb0623f92a600a7b3cba70d9f3ba82164914f267 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster___construct, 0, 0, 1)
55
ZEND_ARG_INFO(0, name)

redis_legacy_arginfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: dbcafdb797bd3a4a656d0e1708715bba10ed7f94 */
2+
* Stub hash: d9cbe3fdc3c4cd1b079427a54ff2b24ac1c21adc */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis___construct, 0, 0, 0)
55
ZEND_ARG_INFO(0, options)

0 commit comments

Comments
 (0)