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

Skip to content

Commit cf63e96

Browse files
Documentation: More docblocks
1 parent 14cd882 commit cf63e96

3 files changed

Lines changed: 165 additions & 4 deletions

File tree

redis.stub.php

Lines changed: 163 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1964,8 +1964,6 @@ public function setRange(string $key, int $index, string $value): Redis|int|fals
19641964
*/
19651965
public function setOption(int $option, mixed $value): bool;
19661966

1967-
/** @return bool|Redis */
1968-
19691967
/**
19701968
* Set a Redis STRING key with a specific expiration in seconds.
19711969
*
@@ -2545,12 +2543,104 @@ public function wait(int $numreplicas, int $timeout): int|false;
25452543

25462544
public function xack(string $key, string $group, array $ids): int|false;
25472545

2546+
/**
2547+
* Append a message to a stream.
2548+
*
2549+
* @see https://redis.io/commands/xadd
2550+
*
2551+
* @param string $key The stream name.
2552+
* @param string $id The ID for the message we want to add. This can be the special value '*'
2553+
* which means Redis will generate the ID that appends the message to the
2554+
* end of the stream. It can also be a value in the form <ms>-* which will
2555+
* generate an ID that appends to the end ot entries with the same <ms> value
2556+
* (if any exist).
2557+
* @param int $maxlen If specified Redis will append the new message but trim any number of the
2558+
* oldest messages in the stream until the length is <= $maxlen.
2559+
* @param bool $approx Used in conjunction with `$maxlen`, this flag tells Redis to trim the stream
2560+
* but in a more efficient way, meaning the trimming may not be exactly to
2561+
* `$maxlen` values.
2562+
* @param bool $nomkstream If passed as `TRUE`, the stream must exist for Redis to append the message.
2563+
*
2564+
* <code>
2565+
* </php
2566+
* <?php
2567+
* $redis = new Redis(['host' => 'localhost']);
2568+
*
2569+
* $redis->del('ds9-season-1');
2570+
*
2571+
* $redis->xAdd('ds9-season-1', '1-1', ['title' => 'Emissary Part 1']);
2572+
* $redis->xAdd('ds9-season-1', '1-2', ['title' => 'A Man Alone']);
2573+
* $redis->xAdd('ds9-season-1', '1-3', ['title' => 'Emissary Part 2']);
2574+
* $redis->xAdd('ds9-season-1', '1-4', ['title' => 'Past Prologue']);
2575+
*
2576+
* // Array
2577+
* // (
2578+
* // [1-1] => Array
2579+
* // (
2580+
* // [title] => Emissary Part 1
2581+
* // )
2582+
* //
2583+
* // [1-2] => Array
2584+
* // (
2585+
* // [title] => A Man Alone
2586+
* // )
2587+
* //
2588+
* // )
2589+
* $redis->xRange('ds9-season-1', '1-1', '1-2');
2590+
* ?>
2591+
* ?>
2592+
* </code>
2593+
*/
25482594
public function xadd(string $key, string $id, array $values, int $maxlen = 0, bool $approx = false, bool $nomkstream = false): Redis|string|false;
25492595

25502596
public function xautoclaim(string $key, string $group, string $consumer, int $min_idle, string $start, int $count = -1, bool $justid = false): Redis|bool|array;
25512597

25522598
public function xclaim(string $key, string $group, string $consumer, int $min_idle, array $ids, array $options): Redis|bool|array;
25532599

2600+
/**
2601+
* Remove one or more specific IDs from a stream.
2602+
*
2603+
* @param string $key The stream to modify.
2604+
* @param array $ids One or more message IDs to remove.
2605+
*
2606+
* @return Redis|int|false The number of messages removed or false on failure.
2607+
*
2608+
* <code>
2609+
* $redis = new Redis(['host' => 'localhost']);
2610+
*
2611+
* $redis->del('stream');
2612+
*
2613+
* for ($a = 1; $a <= 3; $a++) {
2614+
* for ($b = 1; $b <= 2; $b++) {
2615+
* $redis->xAdd('stream', "$a-$b", ['id' => "$a-$b"]);
2616+
* }
2617+
* }
2618+
*
2619+
* // Remove some elements
2620+
* $redis->xDel('stream', ['1-1', '2-1', '3-1']);
2621+
*
2622+
* // Array
2623+
* // (
2624+
* // [1-2] => Array
2625+
* // (
2626+
* // [id] => 1-2
2627+
* // )
2628+
* //
2629+
* // [2-2] => Array
2630+
* // (
2631+
* // [id] => 2-2
2632+
* // )
2633+
* //
2634+
* // [3-2] => Array
2635+
* // (
2636+
* // [id] => 3-2
2637+
* // )
2638+
* //
2639+
* // )
2640+
* $redis->xRange('stream', '-', '+');
2641+
* ?>
2642+
* </code>
2643+
*/
25542644
public function xdel(string $key, array $ids): Redis|int|false;
25552645

25562646
/**
@@ -2650,6 +2740,23 @@ public function xinfo(string $operation, ?string $arg1 = null, ?string $arg2 = n
26502740
*/
26512741
public function xlen(string $key): Redis|int|false;
26522742

2743+
/**
2744+
* Interact with stream messages that have been consumed by a consumer group but not yet
2745+
* acknowledged with XACK.
2746+
*
2747+
* @see https://redis.io/commands/xpending
2748+
* @see https://redis.io/commands/xreadgroup
2749+
*
2750+
* @param string $key The stream to inspect.
2751+
* @param string $group The user group we want to see pending messages from.
2752+
* @param string $start The minimum ID to consider.
2753+
* @param string $string The maximum ID to consider.
2754+
* @param string $count Optional maximum number of messages to return.
2755+
* @param string $consumer If provided, limit the returned messages to a specific consumer.
2756+
*
2757+
* @return Redis|array|false The pending messages belonging to the stream or false on failure.
2758+
*
2759+
*/
26532760
public function xpending(string $key, string $group, ?string $start = null, ?string $end = null, int $count = -1, ?string $consumer = null): Redis|array|false;
26542761

26552762
/**
@@ -2753,6 +2860,60 @@ public function xrange(string $key, string $start, string $end, int $count = -1)
27532860
*/
27542861
public function xread(array $streams, int $count = -1, int $block = -1): Redis|array|bool;
27552862

2863+
/**
2864+
* Read one or more messages using a consumer group.
2865+
*
2866+
* @param string $group The consumer group to use.
2867+
* @param string $consumer The consumer to use.
2868+
* @param array $streams An array of stream names and message IDs
2869+
* @param int $count Optional maximum number of messages to return
2870+
* @param int $block How long to block if there are no messages available.
2871+
*
2872+
* @return Redis|array|bool Zero or more unread messages or false on failure.
2873+
*
2874+
* <code>
2875+
* <?php
2876+
*
2877+
* $redis = new Redis(['host' => 'localhost']);
2878+
*
2879+
* $redis->del('episodes');
2880+
*
2881+
* // Create a consumer group (and stream)
2882+
* $redis->xGroup('CREATE', 'episodes', 'ds9', '0-0', true);
2883+
*
2884+
* // Add a couple of messages to the stream
2885+
* $redis->xAdd('episodes', '1-1', ['title' => 'Emissary: Part 1']);
2886+
* $redis->xAdd('episodes', '1-2', ['title' => 'A Man Alone']);
2887+
*
2888+
* // Now read some messages with our consumer group
2889+
* $messages = $redis->xReadGroup('ds9', 'sisko', ['episodes' => '>']);
2890+
*
2891+
* // After having read the two messages, add another
2892+
* $redis->xAdd('episodes', '1-3', ['title' => 'Emissary: Part 2']);
2893+
*
2894+
* // Acknowledge the first two read messages
2895+
* foreach ($messages as $stream => $stream_messages) {
2896+
* $ids = array_keys($stream_messages);
2897+
* $redis->xAck('stream', 'ds9', $ids);
2898+
* }
2899+
*
2900+
* // We can now pick up where we left off, and will only get the final message
2901+
* $msgs = $redis->xReadGroup('ds9', 'sisko', ['episodes' => '>']);
2902+
*
2903+
* // array(1) {
2904+
* // ["episodes"]=>
2905+
* // array(1) {
2906+
* // ["1-3"]=>
2907+
* // array(1) {
2908+
* // ["title"]=>
2909+
* // string(16) "Emissary: Part 2"
2910+
* // }
2911+
* // }
2912+
* // }
2913+
* var_dump($msgs);
2914+
* ?>
2915+
* </code>
2916+
*/
27562917
public function xreadgroup(string $group, string $consumer, array $streams, int $count = 1, int $block = 1): Redis|array|bool;
27572918

27582919
/**

redis_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: ceb169a872a3df211ded811c1a5ac102832a9158 */
2+
* Stub hash: 42952974e3686f29934dfff1ebba07150942a405 */
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")

redis_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: ceb169a872a3df211ded811c1a5ac102832a9158 */
2+
* Stub hash: 42952974e3686f29934dfff1ebba07150942a405 */
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)