Skip to content

nri-redis: add zcard, zrem, zremrangebyscore to Redis.SortedSet - #161

Merged
omnibs merged 6 commits into
trunkfrom
pd-3565-sortedset-commands
Jul 29, 2026
Merged

nri-redis: add zcard, zrem, zremrangebyscore to Redis.SortedSet#161
omnibs merged 6 commits into
trunkfrom
pd-3565-sortedset-commands

Conversation

@omnibs

@omnibs omnibs commented Jul 29, 2026

Copy link
Copy Markdown
Member

Adds zcard, zrem, and zremrangebyscore to Redis.SortedSet, and bumps nri-redis to 0.4.2.0.

Adding these to support multi-window sliding-window rate limiting (e.g. 60 rpm | 300 req/day | 1k req/mo) built on Redis.transaction (MULTI/EXEC) instead of Lua scripting.

The bump also touches 11 test goldens: they embed the test-suite package version in srcLocPackage, so the suffix has to follow the bump (same situation and same targeted-substitution approach as b62e011).

🤖 Generated with Claude Code

omnibs and others added 4 commits July 29, 2026 00:27
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The test goldens embed the test-suite package version in `srcLocPackage`,
so bumping the version requires the matching suffix update there too.
Applied as a targeted substring substitution rather than a regeneration,
which leaves the recorded source locations untouched.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 29, 2026 04:22
@linear

linear Bot commented Jul 29, 2026

Copy link
Copy Markdown

PD-3565

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends nri-redis’s sorted-set API to support transactional sliding-window rate limiting workflows by adding the missing primitives (ZCARD, ZREM, ZREMRANGEBYSCORE) and bumping the library version accordingly.

Changes:

  • Add zcard, zrem, and zremrangebyscore to Redis.SortedSet, threading the new commands through Redis.Internal and Redis.Handler.
  • Add query-level tests covering the new sorted-set operations.
  • Bump nri-redis to 0.4.2.0 and update observability golden outputs that embed the package version.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
nri-redis/src/Redis/SortedSet.hs Exposes new sorted-set operations on the public SortedSet API record and module exports.
nri-redis/src/Redis/Internal.hs Adds new Query constructors and threads them through cmds, mapKeys, mapReturnedKeys, and keysTouchedByQuery.
nri-redis/src/Redis/Handler.hs Implements execution of the new queries via hedis (Database.Redis.*).
nri-redis/test/Spec/Redis.hs Adds tests validating zcard, zrem, and zremrangebyscore behavior.
nri-redis/package.yaml Bumps package version to 0.4.2.0.
nri-redis/nri-redis.cabal Bumps cabal version to 0.4.2.0.
nri-redis/CHANGELOG.md Documents the new API additions in the 0.4.2.0 release notes.
nri-redis/test/golden-results-9.8/observability-spec-reporting-without-query-timout Updates golden to reflect the new srcLocPackage version string.
nri-redis/test/golden-results-9.8/observability-spec-reporting-with-query-timout Updates golden to reflect the new srcLocPackage version string.
nri-redis/test/golden-results-9.8/observability-spec-reporting-redis-transaction Updates golden to reflect the new srcLocPackage version string.
nri-redis/test/golden-results-9.8/observability-spec-reporting-redis-query-timeout Updates golden to reflect the new srcLocPackage version string.
nri-redis/test/golden-results-9.8/observability-spec-reporting-redis-query Updates golden to reflect the new srcLocPackage version string.
nri-redis/test/golden-results-9.8/observability-spec-reporting-redis-list-transaction Updates golden to reflect the new srcLocPackage version string.
nri-redis/test/golden-results-9.8/observability-spec-reporting-redis-list-query Updates golden to reflect the new srcLocPackage version string.
nri-redis/test/golden-results-9.8/observability-spec-reporting-redis-hash-transaction Updates golden to reflect the new srcLocPackage version string.
nri-redis/test/golden-results-9.8/observability-spec-reporting-redis-hash-query Updates golden to reflect the new srcLocPackage version string.
nri-redis/test/golden-results-9.8/observability-spec-reporting-redis-counter-transaction Updates golden to reflect the new srcLocPackage version string.
nri-redis/test/golden-results-9.8/observability-spec-reporting-redis-counter-query Updates golden to reflect the new srcLocPackage version string.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread nri-redis/src/Redis/SortedSet.hs Outdated
Comment on lines +122 to +126
-- | Removes all members in the sorted set with a score between the two
-- bounds (inclusive). Returns the number of members removed.
--
-- https://redis.io/commands/zremrangebyscore
zremrangebyscore :: key -> Float -> Float -> Internal.Query Int,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call. done.

@omnibs
omnibs requested a review from mandla-noredink July 29, 2026 14:54
@omnibs
omnibs enabled auto-merge July 29, 2026 14:54
@omnibs
omnibs requested a review from juanedi July 29, 2026 16:15
@omnibs
omnibs added this pull request to the merge queue Jul 29, 2026
Merged via the queue into trunk with commit c5da9ed Jul 29, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants