diff options
author | michael-grunder <michael.grunder@gmail.com> | 2022-11-01 03:30:29 +0300 |
---|---|---|
committer | Michael Grunder <michael.grunder@gmail.com> | 2022-11-01 03:47:17 +0300 |
commit | 0dd2836f3c6b55a557850ad655e7f3cfc89cb9a1 (patch) | |
tree | 3410749e04f621bc70a991cf798f7e5bb8e9a1b7 | |
parent | 2a0d1c1e6d10d53c3de510cef4310be912bec4c0 (diff) |
Documentation: Add a docblock for the set command.
-rw-r--r-- | redis.stub.php | 43 | ||||
-rw-r--r-- | redis_arginfo.h | 4 | ||||
-rw-r--r-- | redis_cluster.stub.php | 3 | ||||
-rw-r--r-- | redis_cluster_arginfo.h | 2 | ||||
-rw-r--r-- | redis_cluster_legacy_arginfo.h | 2 | ||||
-rw-r--r-- | redis_legacy_arginfo.h | 8 |
6 files changed, 51 insertions, 11 deletions
diff --git a/redis.stub.php b/redis.stub.php index 7f9d0299..69fda01c 100644 --- a/redis.stub.php +++ b/redis.stub.php @@ -1621,7 +1621,48 @@ class Redis { */ public function select(int $db): Redis|bool; - public function set(string $key, mixed $value, mixed $opt = NULL): Redis|string|bool; + /** + * Create or set a Redis STRING key to a value. + * + * @see https://redis.io/commands/set + * @see https://redis.io/commands/setex + * + * @param string $key The key name to set. + * @param mixed $value The value to set the key to. + * @param array|int $options Either an array with options for how to perform the set or an + * integer with an expiration. If an expiration is set PhpRedis + * will actually send the `SETEX` command. + * + * OPTION DESCRIPTION + * ------------ -------------------------------------------------------------- + * ['EX' => 60] expire 60 seconds. + * ['PX' => 6000] expire in 6000 milliseconds. + * ['EXAT' => time() + 10] expire in 10 seconds. + * ['PXAT' => time()*1000 + 1000] expire in 1 second. + * ['KEEPTTL' => true] Redis will not update the key's current TTL. + * ['XX'] Only set the key if it already exists. + * ['NX'] Only set the key if it doesn't exist. + * ['GET'] Instead of returning `+OK` return the previous value of the + * key or NULL if the key didn't exist. + * + * @return Redis|string|bool True if the key was set or false on failure. + * + * <code> + * <?php + * $redis = new Redis(['host' => 'localhost']); + * + * $redis->set('key', 'value'); + * + * // Will actually send `SETEX 60 key value` to Redis. + * $redis->set('key', 'expires_in_60_seconds', 60); + * + * // Only have Redis set the key if it already exists. + * $redis->set('key', 'options_set', ['XX']); + * + * ?> + * </code> + */ + public function set(string $key, mixed $value, mixed $options = NULL): Redis|string|bool; /** @return Redis|int|false*/ public function setBit(string $key, int $idx, bool $value); diff --git a/redis_arginfo.h b/redis_arginfo.h index 55fd6856..9d28c7d3 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: d59da775ee203c4ec2f7c5a558e07a561a8a501a */ + * Stub hash: 8a3b18f9b816cfb6aac50ef147008d7349496e08 */ 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") @@ -759,7 +759,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_set, 0, 2, Redis, MAY_BE_STRING|MAY_BE_BOOL) ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, opt, IS_MIXED, 0, "NULL") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_MIXED, 0, "NULL") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_setBit, 0, 0, 3) diff --git a/redis_cluster.stub.php b/redis_cluster.stub.php index c7d08fee..f4ff298f 100644 --- a/redis_cluster.stub.php +++ b/redis_cluster.stub.php @@ -428,6 +428,9 @@ class RedisCluster { */ public function sdiffstore(string $dst, string $key, string ...$other_keys): RedisCluster|int|false; + /** + * @see https://redis.io/commands/set + */ public function set(string $key, mixed $value, mixed $options = NULL): RedisCluster|string|bool; public function setbit(string $key, int $offset, bool $onoff): RedisCluster|int|false; diff --git a/redis_cluster_arginfo.h b/redis_cluster_arginfo.h index aaec34eb..88736406 100644 --- a/redis_cluster_arginfo.h +++ b/redis_cluster_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 0a5a8d4a59c4d7929402293be13553ffcaee7c7e */ + * Stub hash: 65c7830c07ea86720c6089dbd0fa7943df0a2ca8 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster___construct, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 1) diff --git a/redis_cluster_legacy_arginfo.h b/redis_cluster_legacy_arginfo.h index e59b904b..ee4cfafa 100644 --- a/redis_cluster_legacy_arginfo.h +++ b/redis_cluster_legacy_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 0a5a8d4a59c4d7929402293be13553ffcaee7c7e */ + * Stub hash: 65c7830c07ea86720c6089dbd0fa7943df0a2ca8 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster___construct, 0, 0, 1) ZEND_ARG_INFO(0, name) diff --git a/redis_legacy_arginfo.h b/redis_legacy_arginfo.h index 6d114e20..5baf9d03 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: d59da775ee203c4ec2f7c5a558e07a561a8a501a */ + * Stub hash: 8a3b18f9b816cfb6aac50ef147008d7349496e08 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis___construct, 0, 0, 0) ZEND_ARG_INFO(0, options) @@ -643,11 +643,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_select, 0, 0, 1) ZEND_ARG_INFO(0, db) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_set, 0, 0, 2) - ZEND_ARG_INFO(0, key) - ZEND_ARG_INFO(0, value) - ZEND_ARG_INFO(0, opt) -ZEND_END_ARG_INFO() +#define arginfo_class_Redis_set arginfo_class_Redis_lPos ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_setBit, 0, 0, 3) ZEND_ARG_INFO(0, key) |