Redis
Redis is an in-memory data structure store, used as a distributed, in-memory key–value database, cache and message broker, with optional durability. Redis supports different kinds of abstract data structures, such as strings, lists, maps, sets, sorted sets, HyperLogLogs, bitmaps, streams, and spatial indexes.[1]
Readings
editActivities
editRedis Environment
editEstablish a Redis environment using one of the following:
Docker Playground
editDocker Playground is a free online Docker environment. It requires no installation or configuration.
- Use Play with Docker. Create an account and/or log in.
- Start an interactive session and add a new instance.
- In the terminal window, enter the following commands:
docker run -d --name=redis-server redis
docker exec -it redis-server bash
redis-cli
Redis in Docker
editYou can use your own Docker environment to run MongoDB.
- Install Docker Desktop or the Docker Engine.
- In a terminal window, run the following commands:
docker run -d --name=redis-server redis
docker exec -it redis-server bash
redis-cli
Install Redis
editInstall Redis on your own system.
- Review Redis: Quick Start
- Download and install Redis.
- Use the following terminal command to start the Redis server:
redis-server
- Use the following terminal command to access the Redis command interface:
redis-cli
Redis Activities
editCreate a Database
edit- Use the following Redis commands to select a database and set initial keys and values:
SELECT 0
MSET "Bulgaria" "45.2" "Canada" "45" "Federated States of Micronesia" "36.1" "Finland" "37.2" "Germany" "40.3" "Japan" "41" "Marshall Islands" "35.6" "Palau" "35" "Turkmenistan" "50.1"
- Use the following Redis command to show existing configuration information:
INFO
Query a Database
edit- Use the following Redis command to show existing keys in the current database:
KEYS *
- Use the following Redis command to show an existing key value in the current database:
GET "Canada"
Create a Key
edit- Use the following Redis command to add a database key:
SET "United States of America" "56.7"
- Use the following Redis command to display the inserted key:
GET "United States of America"
Update a Key
edit- Use the following Redis command to update a database key:
SET "United States of America" "56.5"
- Use the following Redis command to display the updated key:
GET "United States of America"
Delete a Key
edit- Use the following Redis command to update a database key:
DEL "United States of America"
- Use the following Redis command to display the remaining keys:
KEYS *
Remove All Keys
edit- Use the following Redis command to remove all keys:
FLUSHALL
- Use the following Redis command to verify there are no remaining keys:
KEYS *