@@ -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 );
0 commit comments