-
Notifications
You must be signed in to change notification settings - Fork 612
Added support to expire specfic member of a sorted set #1000
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
Added support to expire specfic member of a sorted set #1000
Conversation
@TalZaccai @badrishc With this PR, // Code to reproduce the issue
var header = new RespInputHeader(GarnetObjectType.SortedSet) { SortedSetOp = SortedSetOperation.ZCOLLECT };
Assert.AreEqual(SortedSetOperation.ZCOLLECT, header.SortedSetOp ) // Fails Actual value: ZCARD |
Hey @Vijay-Nirmal, thanks for reaching out! |
@TalZaccai Thought of the same thing as a temp fix, I will do it as part of a separate PR
So formal ;-) |
I am marking it as ready for review but there are 2 pending items before merging this PR
|
Here is the benchmark result, I don't see any much difference between main and this PR with no expiring items. I see very minor change in the item but it could be run to run variant. If you guys have any concern then let me know Main as of 046fcd8
This PR as of c236828
|
Are we supporting Resp format v2? If not why some of the commands has respProtocolVersion flag? |
We do indeed support RESP3, not fully yet though. |
…ay-Nirmal/garnet into new/sorted-set-member-expire
There was a problem hiding this comment.
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 adds support for member-specific expiration in sorted sets by introducing new commands (ZEXPIRE, ZPEXPIRE, ZEXPIREAT, ZPEXPIREAT, ZTTL, ZPTTL, ZEXPIRETIME, ZPEXPIRETIME, ZPERSIST, ZCOLLECT) and updating related APIs, background tasks, and command parsing code.
- Implements new expiration and persistence commands for sorted set members.
- Updates error message handling and API definitions to use new AbortWithErrorMessage overloads.
- Adjusts background object collection tasks and associated configuration options.
Reviewed Changes
Copilot reviewed 34 out of 34 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
libs/server/Resp/Objects/SortedSetCommands.cs | Updates error message construction and adds new command handlers for expiration and TTL commands. |
libs/server/API/GarnetApiObjectCommands.cs | Adds API definitions for the new sorted set expire, persist, and collect commands. |
libs/server/Resp/AdminCommands.cs | Introduces the ZCOLLECT command in the Admin command dispatching logic. |
libs/server/Resp/Objects/ObjectStoreUtils.cs | Provides new overloads for AbortWithErrorMessage to simplify error messaging. |
libs/server/Resp/Parser/RespCommand.cs | Extends parser logic to recognize the new sorted set commands. |
libs/server/host/Configuration/Options.cs and Servers/GarnetServerOptions.cs | Renames and repurposes frequency settings for expired object collection. |
libs/server/StoreWrapper.cs | Adjusts the background collection task to include sorted set collect logic. |
libs/server/CollectionItemBroker.cs | Updates helper methods to use a passed count for next set object retrieval. |
libs/server/Objects/SortedSetObjectImpl.cs | Integrates expiration logic into sorted set operations (add, remove, range, TTL, persist). |
libs/server/API/IGarnetApi.cs | Declares new methods supporting sorted set expiration and persistence. |
libs/server/Storage/Session/ObjectStore/SortedSetOps.cs | Implements new sorted set operations for expire, TTL, persist and collect, integrating with the new API. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of small comments
…ay-Nirmal/garnet into new/sorted-set-member-expire
Adding support for member-specific expiration in a sorted set. This PR adds ZEXPIRE, ZPEXPIRE, ZEXPIREAT, ZPEXPIREAT, ZTTL, ZPTTL, ZEXPIRETIME, ZPEXPIRETIME, ZPERSIST and ZCOLLECT commands to garnet to support this feature.
Since this is a garnet specific command, I used hashset expire API format as the base line. Below is the syntax for each command