@@ -2049,19 +2049,114 @@ public function strlen(string $key);
2049
2049
2050
2050
public function subscribe (array $ channels , callable $ cb ): bool ;
2051
2051
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 ;
2053
2108
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 ;
2055
2129
2056
2130
public function ttl (string $ key ): Redis |int |false ;
2057
2131
2058
2132
/** @return Redis|int|false*/
2059
2133
public function type (string $ key );
2060
2134
2061
2135
/**
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>
2063
2158
*/
2064
- public function unlink (array |string $ key , string ...$ other_keys );
2159
+ public function unlink (array |string $ key , string ...$ other_keys ): Redis | int | false ;
2065
2160
2066
2161
public function unsubscribe (array $ channels ): Redis |array |bool ;
2067
2162
@@ -2094,19 +2189,19 @@ public function xdel(string $key, array $ids): Redis|int|false;
2094
2189
* @see https://redis.io/commands/xgroup/
2095
2190
*
2096
2191
* @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.
2110
2205
* Requires: Key, group.
2111
2206
* @param string $key The STREAM we're operating on.
2112
2207
* @param string $group The consumer group we want to create/modify/delete.
0 commit comments