New article

Redis complete tutorial: installation, first commands and real examples

A practical Redis guide to understand what it is, how to install it on macOS, Linux and Windows, and how to use strings, expirations, counters, lists and hashes from the CLI.

RedisInstallationCLICachingNoSQLExamples
6379default port used by Redis
PINGfastest command to verify the server is responding
TTLbasic primitive to build cache expiration

What matters before you install Redis

Content adapted to the current official Redis installation docs valid as of April 1, 2026.

Model

Redis is not used like a classic relational database

The key idea is simple: operate on keys, keep values compact and use expiration intentionally for cache, sessions and fast counters.

Install

The current official installation path depends on the platform

The official Redis docs still point to Linux, macOS, Windows compatibility through Memurai, and source installation for manual builds.

Practice

The fastest way to learn Redis is with redis-cli

A few commands are enough to understand strings, hashes, lists, counters, expiration and common inspection patterns.

Key idea

Redis is strongest when you need very fast access by key, controlled expiration and simple data structures

It is common to use Redis for cache, sessions, rate limiting, queues, ephemeral state and counters. It can persist data, but in many projects its first practical value is reducing latency and load in front of slower systems.

What Redis is

Redis is an in-memory data store oriented around keys. Instead of thinking in joins, you think in direct access to keys and in native structures like strings, hashes, lists, sets and sorted sets.

When it fits well

Caching database queries, storing sessions, invalidating tokens, building request counters, keeping temporary shopping cart state or protecting APIs with rate limiting.

Where to be careful

Redis is not the natural replacement for a relational model full of complex joins. If the value of the system depends on relational integrity and long historical analytics, Redis is usually complementary, not the whole database.

macOS

Install with Homebrew

brew install redis
brew services start redis
redis-cli ping

For a local macOS setup this is the shortest path. After starting the service, `redis-cli ping` should answer `PONG`.

Linux

Use the package manager or compile from source

sudo apt update
sudo apt install redis-server
redis-cli ping

In Linux, official docs separate distribution packages from source installation. For Debian or Ubuntu, installing `redis-server` is the usual entry point.

Windows

Use the official Windows compatibility path

Official docs point to Memurai for Windows compatibility.
Alternative for development: run Redis in WSL or Docker.

If you work daily in Windows, WSL is often the most predictable developer setup. The current Redis install docs explicitly point Windows users to Memurai.

Source code

Compile Redis manually

wget https://download.redis.io/redis-stable.tar.gz
tar -xzvf redis-stable.tar.gz
cd redis-stable
make
sudo make install

This route is useful when you want more control, need to test source builds or work on environments where packages are not enough.

Start here

Basic commands with redis-cli

redis-cli ping
SET site:name "1938"
GET site:name
DEL site:name

This is the minimal loop: verify the server, write a key, read it and delete it.

Caching

Store data with expiration

SET page:home "<html>...</html>" EX 60
TTL page:home
GET page:home

This pattern is one of the main reasons to add Redis to a web architecture: keep fast data for a short time and let it expire automatically.

Counters

Count requests or events

INCR stats:visits
INCRBY stats:api:requests 5
GET stats:visits

Counters are trivial in Redis and are frequently used for analytics, quotas and lightweight monitoring.

Hashes

Represent a small user object

HSET user:42 name "Ana" role "admin" plan "pro"
HGET user:42 name
HGETALL user:42

Hashes are useful when several fields belong to the same key and you do not need a full relational record with joins.

Lists

Simple queue example

LPUSH queue:emails "send-welcome:42"
LPUSH queue:emails "send-reset:18"
RPOP queue:emails

A list is enough for many simple queue scenarios, especially in internal tools or small background jobs.

Practical pattern

Basic rate limiting by IP

MULTI
INCR rate:ip:203.0.113.10
EXPIRE rate:ip:203.0.113.10 60
EXEC

The idea is straightforward: count requests per IP and expire the key after one minute. If the value crosses your threshold, reject the request.

Verification and first checks

After installation, the first useful check is still `redis-cli ping`. If the answer is not `PONG`, check whether the service is started, whether the port is open and whether your local host and port match the expected values.

Security basics

Redis official docs warn against exposing an unhardened instance to the internet. In practice, keep it behind a firewall, bind only to the interfaces you need and configure authentication if clients must connect remotely.