- Authors
- Name
Introduction to Redis
Redis is an in-memory database in the NoSQL family that stores data in memory. It provides high availability and can be scaled through clustering.
Install Redis
Installing Redis as a standalone instance on Ubuntu is very straightforward.
sudo apt install redis-server
Check Version
When installed via the apt package manager, Redis version 6.0.16 is installed.
redis-server --version
Redis server v=6.0.16 sha=00000000:0 malloc=jemalloc-5.2.1 bits=64 build=a3fdef44459b3ad6
Check Port
Redis uses port 6379 by default.
netstat -nlpt | grep 6379
tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 15184/redis-server
redis-cli
Entering the redis-cli command launches a shell application that allows you to control Redis from the CLI.
$ redis-cli
127.0.0.1:6379> help
redis-cli 6.0.16
To get help about Redis commands type:
"help @<group>" to get a list of commands in <group>
"help <command>" for help on <command>
"help <tab>" to get a list of possible help topics
"quit" to exit
The commands are very simple. You can store a value for a given key using set, and retrieve the value of a specified key using get. You can delete data for a specified key using the del command.
redis-cli
127.0.0.1:6379> set name testname
OK
127.0.0.1:6379> get name
"testname"
127.0.0.1:6379> keys *
1) "name"
127.0.0.1:6379> del name
(integer) 1
127.0.0.1:6379> keys *
(empty array)