Skip to content
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

Support for Hash Field Expiration commands #2715

Open
atakavci opened this issue May 20, 2024 · 1 comment · May be fixed by #2716
Open

Support for Hash Field Expiration commands #2715

atakavci opened this issue May 20, 2024 · 1 comment · May be fixed by #2716

Comments

@atakavci
Copy link
Contributor

atakavci commented May 20, 2024

There is an upcoming set of commands which will provide a new feature of Redis called Hash Field Expiration.
Related development is in progress and could be checked within the Redis branch and initial draft of it here.

To put it simply, hash field expiration will enable expiration for individual fields in a hash, in a way similar to the key expiration functions in Redis.

list of related Redis commands

HEXPIRE - sets the remaining time to live in seconds for individual members of hash
HPEXPIRE - sets the remaining time to live in milliseconds for individual members of hash
HEXPIREAT - sets the expiration time to a UNIX timestamp in seconds for individual members of hash
HPEXPIREAT - sets the expiration time to a UNIX timestamp in milliseconds for individual members of hash
HPERSIST - removes the expiration time for individual members of hash
HTTL - get the remaining time to live in seconds for individual members of hash
HPTTL - get the remaining time to live in milliseconds for individual members of hash
HEXPIRETIME - get the expiration time as a UNIX timestamp in seconds for individual members of hash
HPEXPIRETIME - get the expiration time as a UNIX timestamp in milliseconds for individual members of hash

structure and arguments of commands

commands:

HEXPIRE `key` `seconds` [NX | XX | GT | LT] <`FIELDS `count` `field` [`field` ...]> - for each specified field: set the remaining time to live in seconds
HPEXPIRE `key` `milliseconds` [NX | XX | GT | LT] <`FIELDS` `count` `field` [`field` ...]> - for each specified field: set the remaining time to live in milliseconds
HEXPIREAT `key` `unix-time-seconds` [NX | XX | GT | LT] <`FIELDS` `count` `field` [`field` ...]> - for each specified field: set the expiration time to a UNIX timestamp specified in seconds since the Unix epoch
HPEXPIREAT `key` `unix-time-milliseconds` [NX | XX | GT | LT] <`FIELDS` `count` `field` [field ...]> - for each specified field: set the expiration time to a UNIX timestamp specified in milliseconds since the Unix epoch

arguments:

- `key` must be type of hash 
- `second`, `milliseconds`, `unix-time-seconds`, and `unix-time-milliseconds` are non-negative integers.
- `NX` – set only when the field has no expiration
- `XX` – set only when the field has an existing expiration
- `GT` – set only when the field's new expiration time is greater than current one. 
- `LT` – set only when the field's new expiration time is less than current one. 
- `count` must be a positive integer; number of fields following must match `count`

returns:

- If `key` does not exist: nil
- If `key` exists: an array containing result for each field given in arguments
	2: field deleted because the specified expiration time is due, 
	1: expiration time set/updated, 
	0:  expiration time NOT set/updated (a specified NX | XX | GT | LT condition not met)
	-2: if no such field

commands:

HPERSIST `key` <FIELDS count field [field ...]> - for each specified field: remove the expiration time

arguments:

- `key` must be type of hash 
- `count` must be a positive integer; number of fields following must match `count`

returns:

- If `key `does not exist: nil
- If `key` exists: an array containing result for each field given in arguments
	1: if the expiration time was removed
	-1: if the expiration time was NOT removed (field has no associated expiration time), 
	-2: if no such field

commands:

HEXPIRETIME key <FIELDS count field [field ...]> - for each specified field: get the expiration time as a Unix timestamp in seconds since the Unix epoch
HPEXPIRETIME key <FIELDS count field [field ...]> - for each specified field: get the expiration time as a Unix timestamp in milliseconds since the Unix epoch
HTTL key <FIELDS count field [field ...]> - for each specified field: get the remaining time to live in seconds
HPTTL key <FIELDS count field [field ...]> - for each specified field: get the remaining time to live in milliseconds	

arguments:

- `key` must be type of hash 
- `count` must be a positive integer; number of fields following must match `count`

returns:

- If `key `does not exist: nil
- If `key` exists: an array containing result for each field given in arguments
	expire time: depends on command, either time to live (in seconds/milliseconds) or UNIX timestamp (in seconds/milliseconds)
	1 : if field has no associated expiration time
	-2: if no such field

@atakavci atakavci linked a pull request May 20, 2024 that will close this issue
@mgravell
Copy link
Collaborator

I don't want to merge this until these commands actually land in redis, but we can certainly take a look at the proposal in advance of that 👍

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 a pull request may close this issue.

2 participants