StackExchange.Redis icon indicating copy to clipboard operation
StackExchange.Redis copied to clipboard

Support for new HGETDEL, HGETEX and HSETEX commands

Open atakavci opened this issue 9 months ago • 6 comments

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

atakavci avatar Mar 26 '25 10:03 atakavci

isn't it duplicate to https://github.com/redis/redis/pull/13577 ? my code has conflict with this @sund. https://github.com/redis/redis/pull/13577 has been reviewed as well

samanebi avatar Apr 22 '25 07:04 samanebi

@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.

sundb avatar Apr 22 '25 08:04 sundb

@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

samanebi avatar Apr 22 '25 08:04 samanebi

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

also kind reminder for the PR..

atakavci avatar Apr 22 '25 15:04 atakavci

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

kamisoft-fr avatar May 26 '25 08:05 kamisoft-fr

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 avatar May 26 '25 11:05 mgravell

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 avatar Jul 22 '25 12:07 mgravell

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

mgravell avatar Jul 22 '25 13:07 mgravell

ping @NickCraver @philon-msft for visibility on https://github.com/StackExchange/StackExchange.Redis/pull/2863/commits/1817d93d82228b9d8f0867513e4465984c5ed9be, 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

mgravell avatar Jul 23 '25 09:07 mgravell