valkey-io / valkey-go

A fast Golang Valkey client that supports Client Side Caching and Auto Pipelining.
Apache License 2.0
158 stars 10 forks source link

feature: add ZREMRANGEBYSCORE with additional limit #4

Closed szuecs closed 6 months ago

szuecs commented 7 months ago

feature: add ZREMRANGEBYSCORE with additional limit

context: go-redis https://pkg.go.dev/github.com/go-redis/redis\#Client.ZRangeByScoreWithScores has this, which we use in https://github.com/zalando/skipper/blob/678fc5a604483a527e6b69645f497675e020328c/net/redisclient.go\#L431-L448 to implement one part of a timewindow based rate limit in https://github.com/zalando/skipper/blob/678fc5a604483a527e6b69645f497675e020328c/ratelimit/redis.go\#L235

rueian commented 6 months ago

Hi @szuecs,

Thank you for sharing your use case. However, your use case is ZRANGEBYSCORE, not ZREMRANGEBYSCORE.

It looks like ZREMRANGEBYSCORE doesn't support the WITHSCORES and LIMIT options you are going to add.

szuecs commented 6 months ago

@rueian oops, yes true. We have ZREMRANGEBYSCORE https://github.com/zalando/skipper/blob/678fc5a604483a527e6b69645f497675e020328c/net/redisclient.go#L421 but you are of course right no WTIHSCORES and LIMIT. Somehow I got wrong by scrolling what commands could be missing, but all commands we need seem to be implemented. Thanks for your time looking into it!