Skip to content

DEV: add new HFE commands #1204

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

Merged
merged 1 commit into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions content/commands/hgetdel/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
acl_categories:
- '@write'
- '@hash'
- '@fast'
arguments:
- display_text: key
key_spec_index: 0
name: key
type: key
- arguments:
- display_text: numfields
name: numfields
type: integer
- display_text: field
multiple: true
name: field
type: string
name: fields
token: FIELDS
type: block
arity: -5
categories:
- docs
- develop
- stack
- oss
- rs
- rc
- oss
- kubernetes
- clients
command_flags:
- write
- fast
complexity: O(N) where N is the number of specified fields
description: Returns the value of a field and deletes it from the hash.
group: hash
hidden: false
key_specs:
- RW: true
access: true
begin_search:
spec:
index: 1
type: index
delete: true
find_keys:
spec:
keystep: 1
lastkey: 0
limit: 0
type: range
linkTitle: HGETDEL
since: 8.0.0
summary: Returns the value of a field and deletes it from the hash.
syntax_fmt: "HGETDEL key FIELDS\_numfields field [field ...]"
syntax_str: "FIELDS\_numfields field [field ...]"
title: HGETDEL
---
Get and delete the value of one or more fields of a given hash key. When the last field is deleted, the key will also be deleted.

## Example

```
redis> HSET mykey field1 "Hello" field2 "World" field3 "!"
(integer) 3
redis> HGETALL mykey
1) "field1"
2) "Hello"
3) "field2"
4) "World"
5) "field3"
6) "!"
redis> HGETDEL mykey FIELDS 2 field3 field4
1) "!"
2) (nil)
redis> HGETALL mykey
1) "field1"
2) "Hello"
3) "field2"
4) "World"
redis> HGETDEL mykey FIELDS 2 field1 field2
1) "Hello"
2) "World"
redis> KEYS *
(empty array)
```
20 changes: 20 additions & 0 deletions content/commands/hgetdel/syntax.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
127 changes: 127 additions & 0 deletions content/commands/hgetex/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
---
acl_categories:
- '@write'
- '@hash'
- '@fast'
arguments:
- display_text: key
key_spec_index: 0
name: key
type: key
- arguments:
- display_text: seconds
name: seconds
token: EX
type: integer
- display_text: milliseconds
name: milliseconds
token: PX
type: integer
- display_text: unix-time-seconds
name: unix-time-seconds
token: EXAT
type: unix-time
- display_text: unix-time-milliseconds
name: unix-time-milliseconds
token: PXAT
type: unix-time
- display_text: persist
name: persist
token: PERSIST
type: pure-token
name: expiration
optional: true
type: oneof
- arguments:
- display_text: numfields
name: numfields
type: integer
- display_text: field
multiple: true
name: field
type: string
name: fields
token: FIELDS
type: block
arity: -5
categories:
- docs
- develop
- stack
- oss
- rs
- rc
- oss
- kubernetes
- clients
command_flags:
- write
- fast
complexity: O(N) where N is the number of specified fields
description: Get the value of one or more fields of a given hash key, and optionally
set their expiration.
group: hash
hidden: false
key_specs:
- RW: true
access: true
begin_search:
spec:
index: 1
type: index
find_keys:
spec:
keystep: 1
lastkey: 0
limit: 0
type: range
notes: RW and UPDATE because it changes the TTL
update: true
linkTitle: HGETEX
since: 8.0.0
summary: Get the value of one or more fields of a given hash key, and optionally set
their expiration.
syntax_fmt: "HGETEX key [EX\_seconds | PX\_milliseconds | EXAT\_unix-time-seconds\
\ |\n PXAT\_unix-time-milliseconds | PERSIST] FIELDS\_numfields field\n [field\
\ ...]"
syntax_str: "[EX\_seconds | PX\_milliseconds | EXAT\_unix-time-seconds | PXAT\_unix-time-milliseconds\
\ | PERSIST] FIELDS\_numfields field [field ...]"
title: HGETEX
---
Get the value of one or more fields of a given hash key and optionally set their expirations (time-to-live or TTL).

## Options

The `HGETEX` command supports a set of options:

* `EX seconds` -- Set the specified expiration time, in seconds.
* `PX milliseconds` -- Set the specified expiration time, in milliseconds.
* `EXAT unix-time-seconds` -- Set the specified Unix time at which the field will expire, in seconds.
* `PXAT unix-time-milliseconds` -- Set the specified Unix time at which the field will expire, in milliseconds.
* `PERSIST` -- Remove the TTL associated with the field.

The `EX`, `PX`, `EXAT`, `PXAT`, and `PERSIST` options are mutually exclusive.

## Example

```
redis> HSET mykey field1 "Hello" field2 "World"
(integer) 2
redis> HGETEX mykey EX 120 FIELDS 1 field1
1) "Hello"
redis> HGETEX mykey EX 100 FIELDS 1 field2
1) "World"
redis> HTTL mykey FIELDS 2 field1 field2
1) (integer) 91
2) (integer) 85
redis> HTTL mykey FIELDS 3 field1 field2 field3
1) (integer) 75
2) (integer) 68
3) (integer) -2
...
redis> HTTL mykey FIELDS 3 field1 field2
1) (integer) -2
2) (integer) -2
redis> HGETALL mykey
(empty array)
```
20 changes: 20 additions & 0 deletions content/commands/hgetex/syntax.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading