8000 XTRIM mystream MINID · Issue #1961 · phpredis/phpredis · GitHub
[go: up one dir, main page]

Skip to content

XTRIM mystream MINID #1961

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
thbley opened this issue Apr 11, 2021 · 3 comments · Fixed by #2172
Closed

XTRIM mystream MINID #1961

thbley opened this issue Apr 11, 2021 · 3 comments · Fixed by #2172
Assignees

Comments

@thbley
Copy link
thbley commented Apr 11, 2021

Expected behaviour

It would be great to support xtrim by minimum id.

https://redis.io/commands/xtrim describes:

XTRIM mystream MAXLEN 1000
and
XTRIM mystream MINID 649085820

Actual behaviour

From the readme I get:

/* Trim to exactly 100 messages */
$obj_redis->xTrim('mystream', 100);
/* Let Redis approximate the trimming */
$obj_redis->xTrim('mystream', 100, true);

But I could not find an option to trim by minimum id.

@mrtwenty
Copy link

I have the same problem!

@mrtwenty
Copy link

Expected behaviour

It would be great to support xtrim by minimum id.

https://redis.io/commands/xtrim describes:

XTRIM mystream MAXLEN 1000
and
XTRIM mystream MINID 649085820

Actual behaviour

From the readme I get:

/* Trim to exactly 100 messages */
$obj_redis->xTrim('mystream', 100);
/* Let Redis approximate the trimming */
$obj_redis->xTrim('mystream', 100, true);

But I could not find an option to trim by minimum id.

you can use rawCommand method

$redis = redis(config('redis'));
$res = $redis->info('server');

if (version_compare($res['redis_version'], '6.2.0', '>')) {
    $res = $redis->rawCommand('xtrim', 'mq', 'minid', '1641526331345-2');
    var_dump($res);
}

@thbley
Copy link
Author
thbley commented Oct 9, 2022

Thank You!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
0