-
Notifications
You must be signed in to change notification settings - Fork 23.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add listpack support, hgetf and hsetf commands (#13209)
**Changes:** - Adds listpack support to hash field expiration - Implements hgetf/hsetf commands **Listpack support for hash field expiration** We keep field name and value pairs in listpack for the hash type. With this PR, if one of hash field expiration command is called on the key for the first time, it converts listpack layout to triplets to hold field name, value and ttl per field. If a field does not have a TTL, we store zero as the ttl value. Zero is encoded as two bytes in the listpack. So, once we convert listpack to hold triplets, for the fields that don't have a TTL, it will be consuming those extra 2 bytes per item. Fields are ordered by ttl in the listpack to find the field with minimum expiry time efficiently. **New command implementations as part of this PR:** - HGETF command For each specified field get its value and optionally set the field's expiration time in sec/msec /unix-sec/unix-msec: ``` HGETF key [NX | XX | GT | LT] [EX seconds | PX milliseconds | EXAT unix-time-seconds | PXAT unix-time-milliseconds | PERSIST] <FIELDS count field [field ...]> ``` - HSETF command For each specified field value pair: set field to value and optionally set the field's expiration time in sec/msec /unix-sec/unix-msec: ``` HSETF key [DC] [DCF | DOF] [NX | XX | GT | LT] [GETNEW | GETOLD] [EX seconds | PX milliseconds | EXAT unix-time-seconds | PXAT unix-time-milliseconds | KEEPTTL] <FVS count field value [field value …]> ``` Todo: - Performance improvement. - rdb load/save - aof - defrag
- Loading branch information
Showing
17 changed files
with
3,636 additions
and
749 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
{ | ||
"HGETF": { | ||
"summary": "For each specified field, returns its value and optionally set the field's remaining expiration time in seconds / milliseconds", | ||
"complexity": "O(N) where N is the number of arguments to the command", | ||
"group": "hash", | ||
"since": "8.0.0", | ||
"arity": -5, | ||
"function": "hgetfCommand", | ||
"history": [], | ||
"command_flags": [ | ||
"WRITE", | ||
"DENYOOM", | ||
"FAST" | ||
], | ||
"acl_categories": [ | ||
"HASH" | ||
], | ||
"key_specs": [ | ||
{ | ||
"flags": [ | ||
"RW", | ||
"UPDATE" | ||
], | ||
"begin_search": { | ||
"index": { | ||
"pos": 1 | ||
} | ||
}, | ||
"find_keys": { | ||
"range": { | ||
"lastkey": 0, | ||
"step": 1, | ||
"limit": 0 | ||
} | ||
} | ||
} | ||
], | ||
"reply_schema": { | ||
"oneOf": [ | ||
{ | ||
"description": "Key does not exist.", | ||
"type": "null" | ||
}, | ||
{ | ||
"description": "Array of results", | ||
"type": "array", | ||
"minItems": 1, | ||
"maxItems": 4294967295, | ||
"items": { | ||
"description": "Field value", | ||
"type": "string" | ||
} | ||
} | ||
] | ||
}, | ||
"arguments": [ | ||
{ | ||
"name": "key", | ||
"type": "key", | ||
"key_spec_index": 0 | ||
}, | ||
{ | ||
"name": "condition", | ||
"type": "oneof", | ||
"optional": true, | ||
"arguments": [ | ||
{ | ||
"name": "nx", | ||
"type": "pure-token", | ||
"token": "NX" | ||
}, | ||
{ | ||
"name": "xx", | ||
"type": "pure-token", | ||
"token": "XX" | ||
}, | ||
{ | ||
"name": "gt", | ||
"type": "pure-token", | ||
"token": "GT" | ||
}, | ||
{ | ||
"name": "lt", | ||
"type": "pure-token", | ||
"token": "LT" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "expiration", | ||
"type": "oneof", | ||
"optional": true, | ||
"arguments": [ | ||
{ | ||
"name": "seconds", | ||
"type": "integer", | ||
"token": "EX" | ||
}, | ||
{ | ||
"name": "milliseconds", | ||
"type": "integer", | ||
"token": "PX" | ||
}, | ||
{ | ||
"name": "unix-time-seconds", | ||
"type": "unix-time", | ||
"token": "EXAT" | ||
}, | ||
{ | ||
"name": "unix-time-milliseconds", | ||
"type": "unix-time", | ||
"token": "PXAT" | ||
}, | ||
{ | ||
"name": "persist", | ||
"type": "pure-token", | ||
"token": "PERSIST" | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "FIELDS", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "count", | ||
"type": "integer" | ||
}, | ||
{ | ||
"name": "field", | ||
"type": "string", | ||
"multiple": true | ||
} | ||
] | ||
} | ||
} |
Oops, something went wrong.