Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0dd2836

Browse files
Documentation: Add a docblock for the set command.
1 parent 2a0d1c1 commit 0dd2836

6 files changed

Lines changed: 51 additions & 11 deletions

redis.stub.php

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1621,7 +1621,48 @@ public function script(string $command, mixed ...$args): mixed;
16211621
*/
16221622
public function select(int $db): Redis|bool;
16231623

1624-
public function set(string $key, mixed $value, mixed $opt = NULL): Redis|string|bool;
1624+
/**
1625+
* Create or set a Redis STRING key to a value.
1626+
*
1627+
* @see https://redis.io/commands/set
1628+
* @see https://redis.io/commands/setex
1629+
*
1630+
* @param string $key The key name to set.
1631+
* @param mixed $value The value to set the key to.
1632+
* @param array|int $options Either an array with options for how to perform the set or an
1633+
* integer with an expiration. If an expiration is set PhpRedis
1634+
* will actually send the `SETEX` command.
1635+
*
1636+
* OPTION DESCRIPTION
1637+
* ------------ --------------------------------------------------------------
1638+
* ['EX' => 60] expire 60 seconds.
1639+
* ['PX' => 6000] expire in 6000 milliseconds.
1640+
* ['EXAT' => time() + 10] expire in 10 seconds.
1641+
* ['PXAT' => time()*1000 + 1000] expire in 1 second.
1642+
* ['KEEPTTL' => true] Redis will not update the key's current TTL.
1643+
* ['XX'] Only set the key if it already exists.
1644+
* ['NX'] Only set the key if it doesn't exist.
1645+
* ['GET'] Instead of returning `+OK` return the previous value of the
1646+
* key or NULL if the key didn't exist.
1647+
*
1648+
* @return Redis|string|bool True if the key was set or false on failure.
1649+
*
1650+
* <code>
1651+
* <?php
1652+
* $redis = new Redis(['host' => 'localhost']);
1653+
*
1654+
* $redis->set('key', 'value');
1655+
*
1656+
* // Will actually send `SETEX 60 key value` to Redis.
1657+
* $redis->set('key', 'expires_in_60_seconds', 60);
1658+
*
1659+
* // Only have Redis set the key if it already exists.
1660+
* $redis->set('key', 'options_set', ['XX']);
1661+
*
1662+
* ?>
1663+
* </code>
1664+
*/
1665+
public function set(string $key, mixed $value, mixed $options = NULL): Redis|string|bool;
16251666

16261667
/** @return Redis|int|false*/
16271668
public function setBit(string $key, int $idx, bool $value);

redis_arginfo.h

Lines changed: 2 additions & 2 deletions
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: d59da775ee203c4ec2f7c5a558e07a561a8a501a */
2+
* Stub hash: 8a3b18f9b816cfb6aac50ef147008d7349496e08 */
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")
@@ -759,7 +759,7 @@ ZEND_END_ARG_INFO()
759759
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_Redis_set, 0, 2, Redis, MAY_BE_STRING|MAY_BE_BOOL)
760760
ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0)
761761
ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0)
762-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, opt, IS_MIXED, 0, "NULL")
762+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_MIXED, 0, "NULL")
763763
ZEND_END_ARG_INFO()
764764

765765
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_setBit, 0, 0, 3)

redis_cluster.stub.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,9 @@ public function sdiff(string $key, string ...$other_keys): RedisCluster|array|fa
428428
*/
429429
public function sdiffstore(string $dst, string $key, string ...$other_keys): RedisCluster|int|false;
430430

431+
/**
432+
* @see https://redis.io/commands/set
433+
*/
431434
public function set(string $key, mixed $value, mixed $options = NULL): RedisCluster|string|bool;
432435

433436
public function setbit(string $key, int $offset, bool $onoff): RedisCluster|int|false;

redis_cluster_arginfo.h

Lines changed: 1 addition & 1 deletion
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: 0a5a8d4a59c4d7929402293be13553ffcaee7c7e */
2+
* Stub hash: 65c7830c07ea86720c6089dbd0fa7943df0a2ca8 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster___construct, 0, 0, 1)
55
ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 1)

redis_cluster_legacy_arginfo.h

Lines changed: 1 addition & 1 deletion
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: 0a5a8d4a59c4d7929402293be13553ffcaee7c7e */
2+
* Stub hash: 65c7830c07ea86720c6089dbd0fa7943df0a2ca8 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RedisCluster___construct, 0, 0, 1)
55
ZEND_ARG_INFO(0, name)

redis_legacy_arginfo.h

Lines changed: 2 additions & 6 deletions
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: d59da775ee203c4ec2f7c5a558e07a561a8a501a */
2+
* Stub hash: 8a3b18f9b816cfb6aac50ef147008d7349496e08 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis___construct, 0, 0, 0)
55
ZEND_ARG_INFO(0, options)
@@ -643,11 +643,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_select, 0, 0, 1)
643643
ZEND_ARG_INFO(0, db)
644644
ZEND_END_ARG_INFO()
645645

646-
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_set, 0, 0, 2)
647-
ZEND_ARG_INFO(0, key)
648-
ZEND_ARG_INFO(0, value)
649-
ZEND_ARG_INFO(0, opt)
650-
ZEND_END_ARG_INFO()
646+
#define arginfo_class_Redis_set arginfo_class_Redis_lPos
651647

652648
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Redis_setBit, 0, 0, 3)
653649
ZEND_ARG_INFO(0, key)

0 commit comments

Comments
 (0)