diff options
author | michael-grunder <michael.grunder@gmail.com> | 2022-11-01 20:33:14 +0300 |
---|---|---|
committer | Michael Grunder <michael.grunder@gmail.com> | 2022-11-01 20:53:47 +0300 |
commit | 993408892696040cc4fba0495c8eb9940aaee64d (patch) | |
tree | 14a3e486b25d8918b4dbf615f7b2546cfac85200 | |
parent | 5dbb4eebe464ec8f63d094b516f2ee3f803c61c6 (diff) |
Documentation: Add several more docblocks.
-rw-r--r-- | redis.stub.php | 129 | ||||
-rw-r--r-- | redis_arginfo.h | 20 | ||||
-rw-r--r-- | redis_legacy_arginfo.h | 2 |
3 files changed, 123 insertions, 28 deletions
diff --git a/redis.stub.php b/redis.stub.php index d2ed4449..fd78a7b2 100644 --- a/redis.stub.php +++ b/redis.stub.php @@ -2049,9 +2049,83 @@ class Redis { public function subscribe(array $channels, callable $cb): bool; - public function swapdb(string $src, string $dst): bool; + /** + * Atomically swap two Redis databases so that all of the keys in the source database will + * now be in the destination database and vice-versa. + * + * Note: This command simply swaps Redis' internal pointer to the database and is therefore + * very fast, regardless of the size of the underlying databases. + * + * @see https://redis.io/commands/swapdb + * @see Redis::del() + * + * @param int $src The source database number + * @param int $dst The destination database number + * + * @return Redis|bool Success if the databases could be swapped and false on failure. + * + * <code> + * <?php + * $redis = new Redis(['host' => 'localhost']); + * + * $redis->multi()->select(0) + * ->set('db0-key1', 'value1')->set('db0-key2', 'value2') + * ->select(1) + * ->set('db1-key1', 'value1')->set('db1-key2', 'value2') + * ->select(0) + * ->exec(); + * + * // Array + * // ( + * // [0] => db0-key1 + * // [1] => db0-key2 + * // ) + * print_r($redis->keys('*')); + * + * // Swap db0 and db1 + * $redis->swapdb(0, 1); + * + * // Array + * // ( + * // [0] => db1-key2 + * // [1] => db1-key1 + * // ) + * print_r($redis->keys('*')); + * + * // Swap them back + * $redis->swapdb(0, 1); + * + * // Array + * // ( + * // [0] => db0-key1 + * // [1] => db0-key2 + * // ) + * print_r($redis->keys('*')); + * ?> + * </code> + */ + public function swapdb(int $src, int $dst): Redis|bool; - public function time(): array; + /** + * Retrieve the server time from the connected Redis instance. + * + * @see https://redis.io/commands/time + * + * @return A two element array consisting of a Unix Timestamp and the number of microseconds + * elapsed since the second. + * + * <code> + * <?php + * $redis = new Redis(['host' => 'localhost']); + * + * // Array + * // ( + * // [0] => 1667271026 + * // [1] => 355678 + * // ) + * print_r($redis->time()); + */ + public function time(): Redis|array; public function ttl(string $key): Redis|int|false; @@ -2059,9 +2133,30 @@ class Redis { public function type(string $key); /** - * @return Redis|int|false + * Delete one or more keys from the Redis database. Unlike this operation, the actual + * deletion is asynchronous, meaning it is safe to delete large keys without fear of + * Redis blocking for a long period of time. + * + * @param array|string $key_or_keys Either an array with one or more keys or a string with + * the first key to delete. + * @param string $other_keys If the first argument passed to this method was a string + * you may pass any number of additional key names. + * + * @return Redis|int|false The number of keys deleted or false on failure. + * + * <code> + * <?php + * $redis = new Redis(['host' => 'localhost']); + * + * // OPTION 1: Called with a single array of keys + * $redis->unlink(['key1', 'key2', 'key3']); + * + * // OPTION 2: Called with a variadic number of arguments + * $redis->unlink('key1', 'key2', 'key3'); + * ?> + * </code> */ - public function unlink(array|string $key, string ...$other_keys); + public function unlink(array|string $key, string ...$other_keys): Redis|int|false; public function unsubscribe(array $channels): Redis|array|bool; @@ -2094,19 +2189,19 @@ class Redis { * @see https://redis.io/commands/xgroup/ * * @param string $operation The subcommand you intend to execute. Valid options are as follows - * 'HELP' - Redis will return information about the command - * Requires: none - * 'CREATE' - Create a consumer group. - * Requires: Key, group, consumer. - * 'SETID' - Set the ID of an existing consumer group for the stream. - * Requires: Key, group, id. - * 'CREATECONSUMER - Create a new consumer group for the stream. You must - * also pass key, group, and the consumer name you wish to - * create. - * Requires: Key, group, consumer. - * 'DELCONSUMER' - Delete a consumer from group attached to the stream. - * Requires: Key, group, consumer. - * 'DESTROY' - Delete a consumer group from a stream. + * 'HELP' - Redis will return information about the command + * Requires: none + * 'CREATE' - Create a consumer group. + * Requires: Key, group, consumer. + * 'SETID' - Set the ID of an existing consumer group for the stream. + * Requires: Key, group, id. + * 'CREATECONSUMER' - Create a new consumer group for the stream. You must + * also pass key, group, and the consumer name you wish to + * create. + * Requires: Key, group, consumer. + * 'DELCONSUMER' - Delete a consumer from group attached to the stream. + * Requires: Key, group, consumer. + * 'DESTROY' - Delete a consumer group from a stream. * Requires: Key, group. * @param string $key The STREAM we're operating on. * @param string $group The consumer group we want to create/modify/delete. diff --git a/redis_arginfo.h b/redis_arginfo.h index eabfc658..07a81ef7 100644 --- a/redis_arginfo.h +++ b/redis_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 8c51e9b0082cb7939c7bc8dc226132eede02f420 */ + * Stub hash: 3cd40e39fce29d74a80c4c7627e52a2b2499a1f4 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis___construct, 0, 0, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 0, "null") @@ -845,22 +845,19 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Redis_subscribe, 0, 2, _IS ZEND_ARG_TYPE_INFO(0, cb, IS_CALLABLE, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Redis_swapdb, 0, 2, _IS_BOOL, 0) - ZEND_ARG_TYPE_INFO(0, src, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, dst, IS_STRING, 0) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_swapdb, 0, 2, Redis, MAY_BE_BOOL) + ZEND_ARG_TYPE_INFO(0, src, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, dst, IS_LONG, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Redis_time, 0, 0, IS_ARRAY, 0) +ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_time, 0, 0, Redis, MAY_BE_ARRAY) ZEND_END_ARG_INFO() #define arginfo_class_Redis_ttl arginfo_class_Redis_expiretime #define arginfo_class_Redis_type arginfo_class_Redis_strlen -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_unlink, 0, 0, 1) - ZEND_ARG_TYPE_MASK(0, key, MAY_BE_ARRAY|MAY_BE_STRING, NULL) - ZEND_ARG_VARIADIC_TYPE_INFO(0, other_keys, IS_STRING, 0) -ZEND_END_ARG_INFO() +#define arginfo_class_Redis_unlink arginfo_class_Redis_del ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_unsubscribe, 0, 1, Redis, MAY_BE_ARRAY|MAY_BE_BOOL) ZEND_ARG_TYPE_INFO(0, channels, IS_ARRAY, 0) @@ -868,7 +865,10 @@ ZEND_END_ARG_INFO() #define arginfo_class_Redis_unwatch arginfo_class_Redis___destruct -#define arginfo_class_Redis_watch arginfo_class_Redis_unlink +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_watch, 0, 0, 1) + ZEND_ARG_TYPE_MASK(0, key, MAY_BE_ARRAY|MAY_BE_STRING, NULL) + ZEND_ARG_VARIADIC_TYPE_INFO(0, other_keys, IS_STRING, 0) +ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_Redis_wait, 0, 2, MAY_BE_LONG|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, count, IS_LONG, 0) diff --git a/redis_legacy_arginfo.h b/redis_legacy_arginfo.h index a793ef44..7ec04be9 100644 --- a/redis_legacy_arginfo.h +++ b/redis_legacy_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 8c51e9b0082cb7939c7bc8dc226132eede02f420 */ + * Stub hash: 3cd40e39fce29d74a80c4c7627e52a2b2499a1f4 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis___construct, 0, 0, 0) ZEND_ARG_INFO(0, options) |