Skip to content

Commit 9934088

Browse files
committedNov 1, 2022
Documentation: Add several more docblocks.
1 parent 5dbb4ee commit 9934088

File tree

3 files changed

+123
-28
lines changed

3 files changed

+123
-28
lines changed
 

‎redis.stub.php

+112-17
Original file line numberDiff line numberDiff line change
@@ -2049,19 +2049,114 @@ public function strlen(string $key);
20492049

20502050
public function subscribe(array $channels, callable $cb): bool;
20512051

2052-
public function swapdb(string $src, string $dst): bool;
2052+
/**
2053+
* Atomically swap two Redis databases so that all of the keys in the source database will
2054+
* now be in the destination database and vice-versa.
2055+
*
2056+
* Note: This command simply swaps Redis' internal pointer to the database and is therefore
2057+
* very fast, regardless of the size of the underlying databases.
2058+
*
2059+
* @see https://redis.io/commands/swapdb
2060+
* @see Redis::del()
2061+
*
2062+
* @param int $src The source database number
2063+
* @param int $dst The destination database number
2064+
*
2065+
* @return Redis|bool Success if the databases could be swapped and false on failure.
2066+
*
2067+
* <code>
2068+
* <?php
2069+
* $redis = new Redis(['host' => 'localhost']);
2070+
*
2071+
* $redis->multi()->select(0)
2072+
* ->set('db0-key1', 'value1')->set('db0-key2', 'value2')
2073+
* ->select(1)
2074+
* ->set('db1-key1', 'value1')->set('db1-key2', 'value2')
2075+
* ->select(0)
2076+
* ->exec();
2077+
*
2078+
* // Array
2079+
* // (
2080+
* // [0] => db0-key1
2081+
* // [1] => db0-key2
2082+
* // )
2083+
* print_r($redis->keys('*'));
2084+
*
2085+
* // Swap db0 and db1
2086+
* $redis->swapdb(0, 1);
2087+
*
2088+
* // Array
2089+
* // (
2090+
* // [0] => db1-key2
2091+
* // [1] => db1-key1
2092+
* // )
2093+
* print_r($redis->keys('*'));
2094+
*
2095+
* // Swap them back
2096+
* $redis->swapdb(0, 1);
2097+
*
2098+
* // Array
2099+
* // (
2100+
* // [0] => db0-key1
2101+
* // [1] => db0-key2
2102+
* // )
2103+
* print_r($redis->keys('*'));
2104+
* ?>
2105+
* </code>
2106+
*/
2107+
public function swapdb(int $src, int $dst): Redis|bool;
20532108

2054-
public function time(): array;
2109+
/**
2110+
* Retrieve the server time from the connected Redis instance.
2111+
*
2112+
* @see https://redis.io/commands/time
2113+
*
2114+
* @return A two element array consisting of a Unix Timestamp and the number of microseconds
2115+
* elapsed since the second.
2116+
*
2117+
* <code>
2118+
* <?php
2119+
* $redis = new Redis(['host' => 'localhost']);
2120+
*
2121+
* // Array
2122+
* // (
2123+
* // [0] => 1667271026
2124+
* // [1] => 355678
2125+
* // )
2126+
* print_r($redis->time());
2127+
*/
2128+
public function time(): Redis|array;
20552129

20562130
public function ttl(string $key): Redis|int|false;
20572131

20582132
/** @return Redis|int|false*/
20592133
public function type(string $key);
20602134

20612135
/**
2062-
* @return Redis|int|false
2136+
* Delete one or more keys from the Redis database. Unlike this operation, the actual
2137+
* deletion is asynchronous, meaning it is safe to delete large keys without fear of
2138+
* Redis blocking for a long period of time.
2139+
*
2140+
* @param array|string $key_or_keys Either an array with one or more keys or a string with
2141+
* the first key to delete.
2142+
* @param string $other_keys If the first argument passed to this method was a string
2143+
* you may pass any number of additional key names.
2144+
*
2145+
* @return Redis|int|false The number of keys deleted or false on failure.
2146+
*
2147+
* <code>
2148+
* <?php
2149+
* $redis = new Redis(['host' => 'localhost']);
2150+
*
2151+
* // OPTION 1: Called with a single array of keys
2152+
* $redis->unlink(['key1', 'key2', 'key3']);
2153+
*
2154+
* // OPTION 2: Called with a variadic number of arguments
2155+
* $redis->unlink('key1', 'key2', 'key3');
2156+
* ?>
2157+
* </code>
20632158
*/
2064-
public function unlink(array|string $key, string ...$other_keys);
2159+
public function unlink(array|string $key, string ...$other_keys): Redis|int|false;
20652160

20662161
public function unsubscribe(array $channels): Redis|array|bool;
20672162

@@ -2094,19 +2189,19 @@ public function xdel(string $key, array $ids): Redis|int|false;
20942189
* @see https://redis.io/commands/xgroup/
20952190
*
20962191
* @param string $operation The subcommand you intend to execute. Valid options are as follows
2097-
* 'HELP' - Redis will return information about the command
2098-
* Requires: none
2099-
* 'CREATE' - Create a consumer group.
2100-
* Requires: Key, group, consumer.
2101-
* 'SETID' - Set the ID of an existing consumer group for the stream.
2102-
* Requires: Key, group, id.
2103-
* 'CREATECONSUMER - Create a new consumer group for the stream. You must
2104-
* also pass key, group, and the consumer name you wish to
2105-
* create.
2106-
* Requires: Key, group, consumer.
2107-
* 'DELCONSUMER' - Delete a consumer from group attached to the stream.
2108-
* Requires: Key, group, consumer.
2109-
* 'DESTROY' - Delete a consumer group from a stream.
2192+
* 'HELP' - Redis will return information about the command
2193+
* Requires: none
2194+
* 'CREATE' - Create a consumer group.
2195+
* Requires: Key, group, consumer.
2196+
* 'SETID' - Set the ID of an existing consumer group for the stream.
2197+
* Requires: Key, group, id.
2198+
* 'CREATECONSUMER' - Create a new consumer group for the stream. You must
2199+
* also pass key, group, and the consumer name you wish to
2200+
* create.
2201+
* Requires: Key, group, consumer.
2202+
* 'DELCONSUMER' - Delete a consumer from group attached to the stream.
2203+
* Requires: Key, group, consumer.
2204+
* 'DESTROY' - Delete a consumer group from a stream.
21102205
* Requires: Key, group.
21112206
* @param string $key The STREAM we're operating on.
21122207
* @param string $group The consumer group we want to create/modify/delete.

‎redis_arginfo.h

+10-10
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: 8c51e9b0082cb7939c7bc8dc226132eede02f420 */
2+
* Stub hash: 3cd40e39fce29d74a80c4c7627e52a2b2499a1f4 */
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")
@@ -845,30 +845,30 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Redis_subscribe, 0, 2, _IS
845845
ZEND_ARG_TYPE_INFO(0, cb, IS_CALLABLE, 0)
846846
ZEND_END_ARG_INFO()
847847

848-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Redis_swapdb, 0, 2, _IS_BOOL, 0)
849-
ZEND_ARG_TYPE_INFO(0, src, IS_STRING, 0)
850-
ZEND_ARG_TYPE_INFO(0, dst, IS_STRING, 0)
848+
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_swapdb, 0, 2, Redis, MAY_BE_BOOL)
849+
ZEND_ARG_TYPE_INFO(0, src, IS_LONG, 0)
850+
ZEND_ARG_TYPE_INFO(0, dst, IS_LONG, 0)
851851
ZEND_END_ARG_INFO()
852852

853-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Redis_time, 0, 0, IS_ARRAY, 0)
853+
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_time, 0, 0, Redis, MAY_BE_ARRAY)
854854
ZEND_END_ARG_INFO()
855855

856856
#define arginfo_class_Redis_ttl arginfo_class_Redis_expiretime
857857

858858
#define arginfo_class_Redis_type arginfo_class_Redis_strlen
859859

860-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_unlink, 0, 0, 1)
861-
ZEND_ARG_TYPE_MASK(0, key, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
862-
ZEND_ARG_VARIADIC_TYPE_INFO(0, other_keys, IS_STRING, 0)
863-
ZEND_END_ARG_INFO()
860+
#define arginfo_class_Redis_unlink arginfo_class_Redis_del
864861

865862
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_unsubscribe, 0, 1, Redis, MAY_BE_ARRAY|MAY_BE_BOOL)
866863
ZEND_ARG_TYPE_INFO(0, channels, IS_ARRAY, 0)
867864
ZEND_END_ARG_INFO()
868865

869866
#define arginfo_class_Redis_unwatch arginfo_class_Redis___destruct
870867

871-
#define arginfo_class_Redis_watch arginfo_class_Redis_unlink
868+
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_watch, 0, 0, 1)
869+
ZEND_ARG_TYPE_MASK(0, key, MAY_BE_ARRAY|MAY_BE_STRING, NULL)
870+
ZEND_ARG_VARIADIC_TYPE_INFO(0, other_keys, IS_STRING, 0)
871+
ZEND_END_ARG_INFO()
872872

873873
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_Redis_wait, 0, 2, MAY_BE_LONG|MAY_BE_FALSE)
874874
ZEND_ARG_TYPE_INFO(0, count, IS_LONG, 0)

‎redis_legacy_arginfo.h

+1-1
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: 8c51e9b0082cb7939c7bc8dc226132eede02f420 */
2+
* Stub hash: 3cd40e39fce29d74a80c4c7627e52a2b2499a1f4 */
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)
Please sign in to comment.