@@ -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 /**
0 commit comments