@@ -3268,6 +3268,328 @@ array(1) {
32683268}
32693269~~~
32703270
3271+ ## Streams
3272+
3273+ * [ xAck] ( #xack ) - Acknowledge one or more pending messages
3274+ * [ xAdd] ( #xadd ) - Add a message to a stream
3275+ * [ xClaim] ( #xclaim ) - Acquire ownership of a pending message
3276+ * [ xDel] ( #xdel ) - Remove a message from a stream
3277+ * [ xGroup] ( #xgroup ) - Manage consumer groups
3278+ * [ xInfo] ( #xinfo ) - Get information about a stream
3279+ * [ xLen] ( #xlen ) - Get the length of a stream
3280+ * [ xPending] ( #xpending ) - Inspect pending messages in a stream
3281+ * [ xRange] ( #xrange ) - Query a range of messages from a stream
3282+ * [ xRead] ( #xread ) - Read message(s) from a stream
3283+ * [ xReadGroup] ( #xreadgroup ) - Read stream messages with a group and consumer
3284+ * [ xRevRange] ( #xrevrange ) - Query one or more messages from end to start
3285+ * [ xTrim] ( #xtrim ) - Trim a stream's size
3286+
3287+ ### xAck
3288+ -----
3289+
3290+ ##### * Prototype*
3291+ ~~~ php
3292+ $obj_redis->xAck($stream, $group, $arr_messages);
3293+ ~~~
3294+
3295+ _ ** Description** _ : Acknowledge one or more messages on behalf of a consumer group.
3296+
3297+ ##### * Return value*
3298+ * long* : The number of messages Redis reports as acknowledged.
3299+
3300+ ##### * Example*
3301+ ~~~ php
3302+ $obj_redis->xAck('stream', 'group1', ['1530063064286-0', '1530063064286-1']);
3303+ ~~~
3304+
3305+ ### xAdd
3306+ -----
3307+
3308+ ##### * Prototype*
3309+ ~~~ php
3310+ $obj_redis->xAdd($str_key, $str_id, $arr_message);
3311+ ~~~
3312+
3313+ _ ** Description** _ : Add a message to a stream
3314+
3315+ ##### * Return value*
3316+ * String* : The added message ID
3317+
3318+ ##### * Example*
3319+ ~~~ php
3320+ $obj_redis->xAdd('mystream', "\*", ['field' => 'value']);
3321+ ~~~
3322+
3323+ ### xClaim
3324+ -----
3325+
3326+ ##### * Prototype*
3327+ ~~~ php
3328+ $obj_redis->($str_key, $str_group, $str_consumer, $min_idle_time, [$arr_options]);
3329+ ~~~
3330+
3331+ _ ** Description** _ : Claim ownership of one or more pending messages.
3332+
3333+ #### * Options Array*
3334+ ~~~ php
3335+ $options = [
3336+ /* Note: 'TIME', and 'IDLE' are mutually exclusive */
3337+ 'IDLE' => $value, /* Set the idle time to $value ms */,
3338+ 'TIME' => $value, /* Set the idle time to now - $value */
3339+ 'RETRYCOUNT' => $value, /* Update message retrycount to $value */
3340+ 'FORCE', /* Claim the message(s) even if they're not pending anywhere */
3341+ 'JUSTID', /* Instruct Redis to only return IDs */
3342+ ];
3343+ ~~~
3344+
3345+ ##### * Return value*
3346+ * Array* : Either an array of message IDs along with corresponding data, or just an array of IDs (if the 'JUSTID' option was passed).
3347+
3348+ ##### * Example*
3349+ ~~~ php
3350+ $ids = ['1530113681011-0', '1530113681011-1', '1530113681011-2'];
3351+
3352+ /* Without any options */
3353+ $obj_redis->xClaim(
3354+ 'mystream', 'group1', 'myconsumer1', $ids
3355+ );
3356+
3357+ /* With options */
3358+ $obj_redis->xClaim(
3359+ 'mystream', 'group1', 'myconsumer2', $ids,
3360+ [
3361+ 'IDLE' => time() * 1000,
3362+ 'RETRYCOUNT' => 5,
3363+ 'FORCE',
3364+ 'JUSTID'
3365+ ]
3366+ );
3367+ ~~~
3368+
3369+ ### xDel
3370+ -----
3371+
3372+ ##### * Prototype*
3373+ ~~~ php
3374+ $obj_redis->xDel($str_key, $arr_ids);
3375+ ~~~
3376+
3377+ _ ** Description** _ : Delete one or more messages from a stream.
3378+
3379+ ##### * Return value*
3380+ * long* : The number of messages removed
3381+
3382+ ##### * Example*
3383+ ~~~ php
3384+ $obj_redis->xDel('mystream', ['1530115304877-0', '1530115305731-0']);
3385+ ~~~
3386+
3387+ ### xGroup
3388+ -----
3389+
3390+ ##### * Prototype*
3391+ ~~~ php
3392+ $obj_redis->xGroup('HELP');
3393+ $obj_redis->xGroup('SETID', $str_key, $str_group, $str_msg_id);
3394+ $obj_redis->xGroup('DELGROUP', $str_key, $str_group);
3395+ $obj_redis->xGroup('CREATE', $str_key, $str_group, $str_msg_id);
3396+ $obj_redis->xGroup('DELCONSUMER', $str_key, $str_group, $str_consumer_name);
3397+ ~~~
3398+
3399+ _ ** Description** _ : This command is used in order to create, destroy, or manage consumer groups.
3400+
3401+ ##### * Return value*
3402+ * Mixed* : This command returns different types depending on the specific XGROUP command executed.
3403+
3404+ ##### * Example*
3405+ ~~~ php
3406+ $obj_redis->xGroup('CREATE', 'mystream', 'mygroup');
3407+ $obj_redis->xGroup('DELGROUP', 'mystream', 'mygroup');
3408+ ~~~
3409+
3410+ ### xInfo
3411+ -----
3412+
3413+ ##### * Prototype*
3414+ ~~~ php
3415+ $obj_redis->xInfo('CONSUMERS', $str_stream, $str_group);
3416+ $obj_redis->xInfo('GROUPS', $str_stream);
3417+ $obj_redis->xInfo('STREAM', $str_stream);
3418+ $obj_redis->xInfo('HELP');
3419+ ~~~
3420+
3421+ _ ** Description** _ : Get information about a stream or consumer groups.
3422+
3423+ ##### * Return value*
3424+ * Mixed* : This command returns different types depending on which subcommand is used.
3425+
3426+ ##### * Example*
3427+ ~~~ php
3428+ $obj_redis->xInfo('STREAM', 'mystream');
3429+ ~~~
3430+
3431+ ### xLen
3432+ -----
3433+
3434+ ##### * Prototype*
3435+ ~~~ php
3436+ $obj_redis->xLen($str_stream);
3437+ ~~~
3438+
3439+ _ ** Description** _ : Get the length of a given stream
3440+
3441+ ##### * Return value*
3442+ * Long* : The number of messages in the stream.
3443+
3444+ ##### * Example*
3445+ ~~~ php
3446+ $obj_redis->xLen('mystream');
3447+ ~~~
3448+
3449+ ### xPending
3450+ -----
3451+
3452+ ##### * Prototype*
3453+ ~~~ php
3454+ $obj_redis->xPending($str_stream, $str_group [, $i_start, $i_end, $i_count, $str_consumer]);
3455+ ~~~
3456+
3457+ _ ** Description** _ : Get information about pending messages in a given stream.
3458+
3459+ ##### * Return value*
3460+ * Array* : Information about the pending messages, in various forms depending on the specific invocation of XPENDING.
3461+
3462+ ##### * Examples*
3463+ ~~~ php
3464+ $obj_redis->xPending('mystream', 'mygroup');
3465+ $obj_redis->xPending('mystream', 'mygroup', 0, '+', 1, 'consumer-1');
3466+ ~~~
3467+
3468+ ### xRange
3469+ -----
3470+
3471+ ##### * Prototype*
3472+ ~~~ php
3473+ $obj_redis->xRange($str_stream, $i_start, $i_end [, $i_count]);
3474+ ~~~
3475+
3476+ _ ** Description** _ : Get a range of messages from a given stream.
3477+
3478+ ##### * Return value*
3479+ * Array* : The messages in the stream within the requested range.
3480+
3481+ ##### * Example*
3482+ ~~~ php
3483+ /* Get everything in this stream */
3484+ $obj_redis->xRange('mystream', '-', '+');
3485+
3486+ /* Only the first two messages */
3487+ $obj_redis->xRange('mystream', '-', '+', 2);
3488+ ~~~
3489+
3490+ ### xRead
3491+ -----
3492+
3493+ ##### * Prototype*
3494+ ~~~ php
3495+ $obj_redis->xRead($arr_streams [, $i_count, $i_block);
3496+ ~~~
3497+
3498+ _ ** Description** _ : Read data from one or more streams and only return IDs greater than sent in the command.
3499+
3500+ ##### * Return value*
3501+ * Array* : The messages in the stream newer than the IDs passed to Redis (if any).
3502+
3503+ ##### * Example*
3504+ ~~~ php
3505+ $obj_redis->xRead(['stream1' => '1535222584555-0', 'stream2' => '1535222584555-0']);
3506+
3507+ /* --- Possible output ---
3508+ Array
3509+ (
3510+ [stream1] => Array
3511+ (
3512+ [1535222584555-1] => Array
3513+ (
3514+ [key:1] => val:1
3515+ )
3516+
3517+ )
3518+
3519+ [stream2] => Array
3520+ (
3521+ [1535222584555-1] => Array
3522+ (
3523+ [key:1] => val:1
3524+ )
3525+
3526+ )
3527+
3528+ )
3529+ */
3530+ ~~~
3531+
3532+ ### xReadGroup
3533+ -----
3534+
3535+ ##### * Prototype*
3536+ ~~~ php
3537+ $obj_redis->xReadGroup($str_group, $str_consumer, $arr_streams [, $i_count, $i_block]);
3538+ ~~~
3539+
3540+ _ ** Description** _ : This method is similar to xRead except that it supports reading messages for a specific consumer group.
3541+
3542+ ##### * Return value*
3543+ * Array* : The messages delivered to this consumer group (if any).
3544+
3545+ ##### * Examples*
3546+ ~~~ php
3547+ /* Consume messages for 'mygroup', 'consumer1' */
3548+ $obj_redis->xReadGroup('mygroup', 'consumer1', ['s1' => 0, 's2' => 0]);
3549+
3550+ /* Read a single message as 'consumer2' for up to a second until a message arrives. */
3551+ $obj_redis->xReadGroup('mygroup', 'consumer2', ['s1' => 0, 's2' => 0], 1, 1000);
3552+ ~~~
3553+
3554+ ### xRevRange
3555+ -----
3556+
3557+ ##### * Prototype*
3558+ ~~~ php
3559+ $obj_redis->xRevRange($str_stream, $i_end, $i_start [, $i_count]);
3560+ ~~~
3561+
3562+ _ ** Description** _ : This is identical to xRange except the results come back in reverse order. Also note that Redis reverses the order of "start" and "end".
3563+
3564+ ##### * Return value*
3565+ * Array* : The messages in the range specified.
3566+
3567+ ##### * Example*
3568+ ~~~ php
3569+ $obj_redis->xRevRange('mystream', '+', '-');
3570+ ~~~
3571+
3572+ ### xTrim
3573+ -----
3574+
3575+ ##### * Prototype*
3576+ ~~~ php
3577+ $obj_redis->xTrim($str_stream, $i_max_len [, $boo_approximate]);
3578+ ~~~
3579+
3580+ _ ** Description** _ : Trim the stream length to a given maximum. If the "approximate" flag is pasesed, Redis will use your size as a hint but only trim trees in whole nodes (this is more efficient).
3581+
3582+ ##### * Return value*
3583+ * long* : The number of messages trimed from the stream.
3584+
3585+ ##### * Example*
3586+ ~~~ php
3587+ /* Trim to exactly 100 messages */
3588+ $obj_redis->xTrim('mystream', 100);
3589+
3590+ /* Let Redis approximate the trimming */
3591+ $obj_redis->xTrim('mystream', 100, true);
3592+ ~~~
32713593
32723594## Pub/sub
32733595
0 commit comments