HLS

Apply for Redis Developer Course Redis Regular Inspection / Technical Support Redis Enterprise Server

Get fields and values by a field-name pattern

The usage is hls key field.
You can use a glob-style pattern for Field.

  • * : Matches any characters: h*llo -> hllo, heeeello, etc
  • ? : Matches one character: h?llo -> hallo, hello, hxllo, etc
  • [alphabet] : Matches a character in the brackets: h[ae]llo -> hallo, hello
  • [^e] : Matches any character except those in the brackets: h[^e]llo -> hallo, hbllo, ... but hello is excluded.
  • [a-c] : Matches a character range in the brackets: h[a-c]llo -> hallo, hbllo, hcllo
  • \ : To use the special characters above (*?[^]) as literals, prefix them with \.

Example

Command>hset myhash field1 value1 field2 value2
Result>2
Command>hls myhash *
Result> 1) "field1"
2) "value1"
3) "field2"
4) "value2"
Command>hls myhash field1*
Result> 1) field1
2) value1

Sort feature

Use Sort or asc for ascending order, and desc for descending order. Sorting is by field name.

Example

Command>hls myhash * desc
Result> 1) "field2"
2) "value2"
3) "field1"
4) "value1"

Syntax

HLS key field-pattern [sort|asc|desc]

  • Available since Enterprise version 6.1.0.
  • Time complexity is O(N). N is the number of data items.
  • If there are many values, it can affect performance, so use it carefully.

<< HGETALL HLS HSTRLEN >>

Email 답글이 올라오면 이메일로 알려드리겠습니다.