Redis
Contents
Design Goals
- Fast
- Non-persistent
- Automatic garbage collection ASAP using Redis built-in TTL
- Memory-efficient
Storage Details
This section discusses a mapping between the necessary data and how it is handled at the Redis level.
Queue List
A queue list is nothing more than a list of queues. This creates a mapping from tenants to queues they've created.
Key | Value |
---|---|
q.project_id | [q.project_id.name1, q.project_id.name2, ...] |
Great candidate for representing these are Redis sets. The O(1) deletion is very important.
Queue Item
A queue item contains the following:
- Queue metadata
- Queue configuration (coming later)
- Queue stats
- A list of message (key) ids for this queue
Key | Value |
---|---|
q.project_id.name | msgpack |
Plain keys work fine here.
Message List
This creates a mapping from queues to messages.
Key | Value |
---|---|
q.project_id.name.m | [q.project_id.name.msg1, q.project_id.name.msg2, ...] |
Great candidate for representing these are Redis sets. The O(1) deletion is very important.
Message Item
A message item contains the following:
- href
- body
- claim ID (status == 'active' if claim ID is not set)
The TTL and age are set in such a way that Redis handles them.
Key | Value |
---|---|
q.project_id.name.msg_id | msgpack |
Plain keys work fine here. Need to take advantage of expires.
Claim
A claim is a collection of messages to be processed. They carry:
Key | Value |
---|---|
q.project_id.name.cid | [q.project_id.name.msg1, q.project_id.name.msg2, ...] |
A Redis set works well here.