Basic Redis Types and Commands
Notewriting
This article shows some basic Redis data types and their commands using in this site.
Data types
Redis sets
Introduction to Redis sets
A Redis set is an unordered collection of unique strings (members). You can use Redis sets to efficiently:
- Track unique items (e.g., track all unique IP addresses accessing a given blog post).
- Represent relations (e.g., the set of all users with a given role).
- Perform common set operations such as intersection, unions, and differences.
Basic commands
Command | Description |
---|---|
SADD | adds a new member to a set. |
SREM | removes the specified member from the set. |
SISMEMBER | tests a string for set membership. |
SINTER | returns the set of members that two or more sets have in common (i.e., the intersection). |
SCARD | returns the size (a.k.a. cardinality) of a set. |
SMEMBERS | returns all the members of the set value stored at key. |
See the complete list of set commands.
Used for
Sets type is used for storing the collections of unique ip strings who liked this site today.
Deploy and Run Redis in Docker
Please refer to this article, How to Deploy and Run Redis in a Docker Container
In particular, it shows how to use Redis-Client in docker: Step 3: Connect to your database
The following uses the first three alphanumeric characters of your Container ID and opens up sh shell of the Redis Docker container:
$ docker exec -it 885 sh
> redis-cli
Excalidraw Loading...