Redis: How to get started
Redis (Remote Dictionary Server) is a NoSQL in memory database which can be used for caching, queues, leader boards, session store, geospatial data, media streaming, real time analytics.
Felix Bärtschi
Redis (Remote Dictionary Server) is an in-memory NoSQL database that can be used for caching, queues, leaderboards, session store, geospatial data, media streaming, realtime analytics.

Redis has a response time below 1 millisecond and is ideal for real-time applications.
Redis runs only on Linux, however you can install it on a Windows machine as well.
Once Redis is installed, you can start the Redis server with the following command:
redis-server

Redis-Server
Leave the terminal open at all time. If the terminal gets closed, the server will be terminated.
CLI
Redis comes with a CLI (Command Line Interface) for easy access and manipulation on the Database. In order to open the CLI open another Terminal
redis-cli

Redis CLI connection test
Data Types
Redis has several data types:
- String (Serves as a Key: Value pair similar to a dictionary in python)
- List (Sorted data type)
- Sets (Same as List but cannot be sorted)
- Hashes (field of value pairs)
- Sorted Sets (The only sorted data type beside the List)
- Streams (Adding new values to a stream like logs or a chat)
- Geospatial (Storing longitude and latitude)
- Hyper Log Log (estimates unique values with a standard error of 0.81%)
- Bitmaps (evolved string data type which allows you to to bitwise operations)
- Bitfields (incrementing automatically values)
Basic Commands
Based on the Date Type you are using you got different commands available.I will show you some basic commands to get started with the data type String (the most common one). For a more comprehensive list, check out the documentation
Commands In the CLI:
Write a new Key-Value pair in the Redis Database
set “key” “value”
Read a value based on a key from the Redis DB
get “key”
Get all they Key’s stored in the Redis DB
KEYS *
Increment a counter by one
INCR "key"
Commands In Python:
Set up connection to the Redis DB
import redis as rhost = "localhost"
port = '6379'
r = redis.Redis(
host = host,
port = port,
decode_responses=True,
)
Write a new Key-Value pair in the Redis Database
r.set('key','value')
Read a value based on a key from the Redis DB
r.get('key')
Increment a counter by one
r.incr('key')
Upvote
Felix Bärtschi
Programming as an intellectual activity is the only art form that allows you to create interactive art.

Related Articles