-
Notifications
You must be signed in to change notification settings - Fork 472
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
Implement CAS and CAD commands for string type #415
Conversation
lgtm, cool job! After merging this PR, i think we should support EXAT PXAT options for SET and CAS, since these options are frequently-used and friendly, WDYT? @caipengbo @git-hulk |
Yeah, we should be as compliant with Redis commands as possible. |
@caipengbo Could update our wiki https://github.com/KvrocksLabs/kvrocks/wiki/Support-Commands for these new commands |
I want to update the wiki, but I don't have permission @ShooterIT |
oh, let me update |
CAS, set its value to new value when the current value of the string corresponding to key is equal to old value. - syntax: CAS key old_value new_value [EX seconds | PX milliseconds] - return value: returns 1 if the value is successfully updated, -1 if the key does not exist, and 0 if the value fails to be updated CAD, delete the key when the value is equal to the value in the db. - syntax: CAD key value - return value: returns 1 if the value is successfully updated, -1 if the key does not exist, and 0 if the value fails to be updated More details, please see apache#415
CAS, set its value to new value when the current value of the string corresponding to key is equal to old value. - syntax: CAS key old_value new_value [EX seconds | PX milliseconds] - return value: returns 1 if the value is successfully updated, -1 if the key does not exist, and 0 if the value fails to be updated CAD, delete the key when the value is equal to the value in the db. - syntax: CAD key value - return value: returns 1 if the value is successfully updated, -1 if the key does not exist, and 0 if the value fails to be updated More details, please see #415
Since we have already implemented these options in SET / GETEX, the change is very simple. Some ref links: - CAS was added in apache#415 - SET EXAP / PXAT options was added in apache#901 - GETEX was added in apache#961
CAS
This command can be used to atomic change the value of a specified key to a new value if the current value of the key matches a specified value. The value is not changed if the current value of the key does not match the specified value.
Syntax:
Parameters:
Returned values:
CAD
This command can be used to atomic delete a specified key if the current value of the key matches a specified value. The key is not deleted if the current value of the key does not match the specified value.
Syntax:
Parameters:
Returned values: