HGETEX

语法
HGETEX key [EX seconds | PX milliseconds | EXAT unix-time-seconds |
  PXAT unix-time-milliseconds | PERSIST] FIELDS numfields field
  [field ...]
可用版本
Redis 开源版 8.0.0
时间复杂度
O(N),其中 N 为指定字段的数量
ACL 类别
@write, @hash, @fast,

获取给定哈希键中一个或多个字段的值,并可选择设置它们的过期时间或生存时间 (TTL)。

选项

HGETEX 命令支持一组选项

  • EX seconds -- 设置指定的过期时间,以秒为单位。
  • PX milliseconds -- 设置指定的过期时间,以毫秒为单位。
  • EXAT unix-time-seconds -- 设置字段将过期的指定 Unix 时间戳,以秒为单位。
  • PXAT unix-time-milliseconds -- 设置字段将过期的指定 Unix 时间戳,以毫秒为单位。
  • PERSIST -- 移除字段关联的 TTL。

EXPXEXATPXATPERSIST 选项互斥。

示例

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)

RESP2/RESP3 回复

  • 数组回复:与给定字段关联的值列表,顺序与请求顺序相同。

评价此页
返回顶部 ↑