메모리 내 데이터 구조 저장소(in-memory data structure store)
⇒ DB, 캐시, 메시지 브로커, 스트리밍엔진 등으로 쓰임
Key - Value 저장소
다른 인메모리 DB와의 차이점
다양한 자료구조를 지원함.
@nestjs/bull
에 쓰이는 redis 메시지 큐 명령어 정리HGETALL
HGETALL key
<aside>
💡 Returns all fields and values of the hash stored at key
. In the returned value, every field name is followed by its value, so the length of the reply is twice the size of the hash.
</aside>
해시 스토어에 있는 값을 키를 이용해 가져오는 명령어이다.
BRPOPLPUSH
BRPOPLPUSH source destination timeout
<aside>
💡 Atomically returns and removes the last element (tail) of the list stored at source
, and pushes the element at the first element (head) of the list stored at destination
.
</aside>
B(blocking) RPOP, LPUSH. 즉 두 명령어를 동기적으로 실행하는 명령어이다. source의 가장 오른쪽(마지막) 원소를 pop하고 destination의 왼쪽(처음)에 push한다. 이 과정이 다른 명령어에 의해 나누어지지 않고 원자적으로 실행된다.
추가적으로 blocking이 되기 때문에 타임아웃을 초 단위로 설정할 수 있다.
LPUSH
LPUSH key element [element ...]
<aside>
💡 Insert all the specified values at the head of the list stored at key
. If **key
**does not exist, it is created as empty list before performing the push operations. When key
holds a value that is not a list, an error is returned.
</aside>
key에 저장된 목록의 맨 앞에 element를 삽입한다.
뒤에 입력된 element일수록 앞에 추가된다. 예를 들어 LPUSH key a b c
와 같이 입력되었을 때 c가 가장 맨 앞에, 그리고 b, c가 추가된다.
@nestjs/bull
이용해서 메시지 큐 사용해보기app.module.ts
에 redis 연결하기
Producer
만들기
Consumer
만들기
Redis GUI Tool : Medis