LS   (list)

Redis Developer Course Redis Technical Support Redis Enterprise Server

Key를 조회

사용법은 ls 또는 ls key_pattern 이다.
ls는 키를 조회합니다.

Example

명령>ls     아무 옵션이 없으면 key를 조회
결과> 0) user-1
1) user-2
2) user-30
3) myset
4) meset
5) miset

glob-style pattern을 사용할 수 있습니다.
  • * : 모든 문자 매치(match): h*llo -> hllo, heeeello, etc
  • ? : 1개 문자 매치(match): h?llo -> hallo, hello, hxllo, etc
  • [alphabet] : 대괄호 안에 있는 문자 매치(match): h[ae]llo -> hallo, hello
  • [^e] : 대괄호 안에 있는 문자 제외하고 매치(match): h[^e]llo -> hallo, hbllo, ... 그러나 hello는 제외됨.
  • [a-c] : 대괄호 안에 있는 문자 범위로 매치(match): h[a-c]llo -> hallo, hbllo, hcllo
  • \ : 위에 사용한 특수문자(*?[^])를 그대로 사용하려면 앞에 \를 붙이세요.

Example

명령>ls *   모든 key 조회
결과> 0) user-1
1) user-2
2) user-30
3) myset
4) meset
5) miset
명령>ls user-*   user-로 시작하는 key 조회
결과> 0) user-1
1) user-2
2) user-30
명령>ls *set   set로 끝나는 key 조회
결과> 0) myset
1) meset
2) miset
명령>ls user-?   user-로 시작하고 한 문자만 있는 key 조회
결과> 0) user-1
1) user-2
명령>ls m[ye]set   m으로 시작하고 y or e 가 있고 set으로 끝나는 key 조회
결과> 0) myset
1) meset

애니메이션 보기


Data type 지정

데이터 타입을 지정해서 해당 키들만 조회할 수 있습니다. 지정할 수 있는 데이터 타입은 string, list, set, zset, hash, stream 입니다.

  • 데이터 타입을 지정하면 전체 키 집합에서 찾는 것이 아니고 데이터 타입별로 별도로 관리되는 Hash Table(Dictionary)에서 키를 조회합니다.

Example

명령>ls * string
결과>1) "key1"
2) "key2"
3) "key3"

명령문

LS   [key_pattern] [string|list|set|zset|hash|stream]   [COUNT count]

  • 이 명령은 Ent 8.1.0 부터 사용할 수 있다.
  • 논리적 처리 소요시간: O(N)이다.
관련 명령 SCAN, DBSIZE

<< KEYS LS LL >>

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