Redis COMMAND

Redis Server Course Redis Technical Support Redis Enterprise Server

Redis COMMAND

레디스 명령 정보를 조회합니다.   이 문서는 버전 6.0.6를 기준으로 만들었습니다.

항목 설명

  1. 명령 자체: 예) set, get, dbsize
  2. 명령을 포함한 인수 개수: 예) dbsize는 단독으로 사용되므로 1, get key는 2, set key value [option] 처럼 옵션이 있는 경우는 필수 개수라는 의미로 -3을 표시한다.
  3. 플래그(flag): 명령의 역할/형태 등을 구분하는 용도로 14개가 있다. 자세한 설명은 아래 플래그 설명을 참고하세요.
  4. 첫 번째 키의 위치: 키와 관련된 명령은 대부분 1이다. DBSIZE 처럼 키가 필요없는 명령은 0이다.
  5. 마지막 키의 위치: 대부분 1이지만, SMOVE 같이 키가 2개 필요한 경우는 2이고, MSET, MGET 같이 여러 개 키를 사용할 수 있어서 키 개수를 정할 수 없는 경우에는 -1 이다.
  6. 반복되는 키 위치: MGET key1 key2 같은 경우는 1이고, MSET key1 value1 key2 value2 같은 경우는 2이다.
  7. 명령이 속한 그룹: 한 명령이 여러 개 그룹에 속할 수 있습니다.
    get 명령은 @read, @string, @fast 이고 set 명령은 @write, @string, @slow 이다.
    버전 6에서 ACL 기능을 추가하면서 필요로 이 항목이 추가되었습니다.
    그룹 종류: @keyspace, @read, @write, @set, @sortedset, @list, @hash, @string, @bitmap, @hyperloglog, @stream, @admin, @fast, @slow, @pubsub, @blocking, @dangerous, @connection, @transaction, @scripting, @geo.

플래그 설명

  • write: 저장(insert)/수정(update)/삭제(delete) 명령이다. SET, LPUSH, SADD, LPOP, DEL 등 75개 명령이 있다.
  • readonly: 조회 명령이다. GET, GETRANGE, LLEN, DBSIZE 등 61개 명령이 있다.
  • denyoom: OOM(Out Of Memory)일 때 명령 실행이 거부되는 명령이다. Write 명령 중 저장(insert)/수정(update) 명령이 여기에 해당한다. SET, LPUSH, SADD 등 44개 명령이 있다. LPOP, DEL 같이 삭제 명령은 여기에 해당하지 않는다.
  • admin: 서버 관리용 명령이다. CONFIG, CLIENT, CLUSTER 등 17개 명령이 있다. 이 명령들은 monitor에 잡히지 않는다.
  • pubsub: Pubsub 명령이다. PUBLISH, SUBSCRIBE 등 6개 명령이 있다.
  • noscript: 스크립트에서 사용할 수 없는 명령이다. PLPOP 같은 blocking 명령들, Pubsub 명령들, Admin 명령들이 여기에 속한다. 28개 명령이 있다.
  • random: 명령 결과가 랜덤(random)이다. 스크립트에서 사용하기에 위험하다. SPOP, SRANDMEMBER, RANDOMKEY, SCAN, SSCAN 등 10개 명령이 있다.
  • sort_for_script: 스크립트에서 호출하면 정렬 결과가 나온다. SDIFF, SINTER 등으로 7개 명령이 있다.
  • loading: RDB/AOF 파일을 로딩중에도 사용할 수 있는 명령이다. Pubsub 명령을 사용할 수 있고, 서버 정보를 보는 INFO, 설정을 변경할 수 있는 CONFIG, 성능을 관찰하는 LATENCY 명령 등 17개 명령이 있다. 키 관련 명령은 사용할 수 없다. 로딩중에는 PING에도 응답하지 않는다.
  • stale: 복제에 문제가 있어서 최신 데이터가 아니어도(stale data) 사용할 수 있는 명령이다. 위에서 설명한 loading 명령을 대부분 사용할 수 있고 추가로 PING, SLAVEOF 명령을 사용할 수 있다. 17개 명령이 있다.
  • skip_monitor: Admin 명령이 아니면서 Monitor에 잡히지 않는 명령이다. EXEC 1개 명령이 있다.
  • asking: 클러스터 노드에서 슬롯이 오픈되어(importing/migrating) 있는 중에도 사용할 수 있는 명령이다. RESTORE-ASKING 1개 명령이 있다.
  • fast: 명령 실행 시간이 log(1) 또는 log(N) 인 명령이다. 73개 명령이 있다.   LATENCY 명령에서 실행 시간을 fast command와 일반 command로 구분해서 보여준다. 명령 리스트는 여기를 보세요.
  • movablekeys: 새로운 데이터(키)를 생성하는 명령이다. zinterstore, zunionstore, sort, migrate 등 10개 명령이 있다.

플래그 내부 표시 변경: ver 5 -> ver 6

버전 6에서 ACL 기능이 추가되면서 의미를 좀 더 명확히 하기 위해 변경되었다.
  • w: write command (may modify the key space).
    write: Write command (may modify the key space).
  • r: read command (will never modify the key space).
    read-only: All the non special commands just reading from keys without changing the content, or returning other informations like the TIME command. Special commands such administrative commands or transaction related commands (multi, exec, discard, ...) are not flagged as read-only commands, since they affect the server or the connection in other ways.
  • m: may increase memory usage once called. Don't allow if out of memory.
    use-memory(denyoom): May increase memory usage once called. Don't allow if out of memory.
  • a: admin command, like SAVE or SHUTDOWN.
    admin: Administrative command, like SAVE or SHUTDOWN.
  • p: Pub/Sub related command.
    pub-sub: Pub/Sub related command.
  • s: command not allowed in scripts.
    no-script: Command not allowed in scripts.
  • R: random command. Command is not deterministic, that is, the same command with the same arguments, with the same key space, may have different results. For instance SPOP and RANDOMKEY are two random commands.
    random: Random command. Command is not deterministic, that is, the same command with the same arguments, with the same key space, may have different results. For instance SPOP and RANDOMKEY are two random commands.
  • S: Sort command output array if called from script, so that the output is deterministic.
    to-sort(sort_for_script): Sort command output array if called from script, so that the output is deterministic. When this flag is used (not always possible), then the "random" flag is not needed.
  • l: Allow command while loading the database.
    ok-loading: Allow the command while loading the database.
  • t: Allow command while a slave has stale data but is not allowed to server this data. Normally no command is accepted in this condition but just a few.
    ok-stale: Allow the command while a slave has stale data but is not allowed to serve this data. Normally no command is accepted in this condition but just a few.
  • M: Do not automatically propagate the command on MONITOR.
    no-monitor(skip_monitor): Do not automatically propagate the command on MONITOR.
  • no-slowlog: Do not automatically propagate the command to the slowlog. auth, exec, hello, acl
  • k: Perform an implicit ASKING for this command, so the command will be accepted in cluster mode if the slot is marked as 'importing'.
    cluster-asking: Perform an implicit ASKING for this command, so the command will be accepted in cluster mode if the slot is marked as 'importing'.
  • F: Fast command: O(1) or O(log(N)) command that should never delay its execution as long as the kernel scheduler is giving us time. Note that commands that may trigger a DEL as a side effect (like SET) are not fast commands.
    fast: Fast command: O(1) or O(log(N)) command that should never delay its execution as long as the kernel scheduler is giving us time. Note that commands that may trigger a DEL as a side effect (like SET) are not fast commands.
  • f: force replication of this command, regardless of server.dirty.
    ver 5까지 플래그만 있었고 지정된 명령은 없었다. 6.0에서 제거되었습니다.

명령 실행 결과

버전 6.0.6에서 실행한 결과입니다.


명령문

COMMAND

  • 이 명령은 version 2.8.13 부터 사용할 수 있다.
  • 일곱 번째 항목은 버전 6에서 추가되었습니다.
  • 논리적 처리 소요시간은 O(N)입니다. N은 명령수입니다.

<< RESET COMMAND COMMAND COUNT >>

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