Skip to content

Support for new HGETDEL, HGETEX and HSETEX commands #2863

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

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

atakavci
Copy link
Contributor

This PR adds support for new Redis Hash Commands;

  • HGETDEL
    Get and delete the value of one or more fields of a given hash key
HGETDEL <key> FIELDS <numfields> field [field ...]
  • HGETEX
    Get the value of one or more fields of a given hash key, and optionally set their expiration
  HGETEX <key>  
     [EX seconds | PX milliseconds | EXAT unix-time-seconds | PXAT unix-time-milliseconds | PERSIST] 
     FIELDS <numfields> field [field ...]
  • HSETEX
    Set the value of one or more fields of a given hash key, and optionally set their expiration
  HSETEX <key>
   [FNX | FXX]
   [EX seconds | PX milliseconds | EXAT unix-time-seconds | PXAT unix-time-milliseconds | KEEPTTL] 
   FIELDS <numfields> field value [field value...]

Here the implementation consist of sync and async API s for those commands with adding Lease versions of them when useful.

  • HashFieldGetAndDelete
  • HashFieldGetAndSetExpiry
  • HashFieldSetAndSetExpiry

For more details on commands 👉redis/redis#13798
Redis release including new hash commands 👉https://github.com/redis/redis/releases/tag/8.0-m04

@samanebi
Copy link

samanebi commented Apr 22, 2025

isn't it duplicate to redis/redis#13577 ? my code has conflict with this @sund. redis/redis#13577 has been reviewed as well

@sundb
Copy link

sundb commented Apr 22, 2025

@samanebi ohh, sorry, now this PR is the subset of #13798, we should have set you as the coauther of another PR, so sorry for you.

@samanebi
Copy link

@samanebi ohh, sorry, now this PR is the subset of #13798, we should have set you as the coauther of another PR, so sorry for you.

It is sad to hear that. thanks for putting me as coauthor of another PR. please let me know about that. thanks

@atakavci
Copy link
Contributor Author

@mgravell @NickCraver , i guess there is flaky test showing up with failed tests: DisconnectAndNoReconnectThrowsConnectionExceptionAsync

also kind reminder for the PR..

@kamisoft-fr
Copy link

Hi gents, the PR is pretty old now
but I guess there is a good amount of folks here interested in the support of these commands with the new REDIS V8 release
Is this PR still relevant or needs to be re-written as we speak ?
cheers

@mgravell
Copy link
Collaborator

I'm currently very much in a "Redis" mode (although I'm focusing on a memory thing right now); I will evaluate this in the coming week (public holiday for the UK today)

@mgravell
Copy link
Collaborator

mgravell commented Jul 22, 2025

I'll take care of the drift/merge, but I might tweak some naming for consistency with the String* twins. In particular (using the names from this PR):

  • HGETEX,
    • HashFieldGetAndSetExpiry vs StringGetSetExpiry
  • HGETDEL,
    • HashFieldGetAndDelete vs StringGetDelete
    • HashFieldGetLeaseAndDelete vs (no twin)
  • HSETEX,
    • HashFieldSetAndSetExpiry vs StringSet (with additional args)

@mgravell
Copy link
Collaborator

more thinking; I think I'll leave the And - we use that other places, think GetSearchAndStore, StreamAcknowledgeAndDelete

Still thinking about the AndSetExpiry - overload would seem preferable there

}

// Default case when neither expiry nor persist are set
return Message.Create(Database, flags, RedisCommand.HGETEX, RedisLiterals.FIELDS, 1, hashField);
Copy link
Collaborator

Choose a reason for hiding this comment

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

don't fix (I'm on it), but: missing key here

@@ -81,6 +81,45 @@ public bool HashDelete(RedisKey key, RedisValue hashField, CommandFlags flags =
public bool HashExists(RedisKey key, RedisValue hashField, CommandFlags flags = CommandFlags.None) =>
Inner.HashExists(ToInner(key), hashField, flags);

public RedisValue HashFieldGetAndDelete(RedisKey key, RedisValue hashField, CommandFlags flags = CommandFlags.None) =>
Inner.HashFieldGetAndDelete(key, hashField, flags);
Copy link
Collaborator

Choose a reason for hiding this comment

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

needs ToInner on all key usage (I'll do this - I'll read all the pre-existing too; I might write a code-generator for this file!)

… new code, this includes pre-existing bugs:

- SetIntersectionLength
- SortedSetCombine
- SortedSetCombineWithScores
- SortedSetIntersectionLength
@mgravell
Copy link
Collaborator

ping @NickCraver @philon-msft for visibility on 1817d93, in particular because of the pre-existing missing usage in

  • SetIntersectionLength
  • SortedSetCombine
  • SortedSetCombineWithScores
  • SortedSetIntersectionLength

I'll call these out on the release notes, and probably worth a "minor" bump

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 this pull request may close these issues.

5 participants