Updated guide
Redis complete tutorial: Redis 8, installation, CLI and real examples
A practical Redis guide to understand cache, sessions and rate limiting, updated with Redis 8, current installation commands, licensing context and Valkey compatibility.
What matters before you install Redis
Content updated for Redis 8, the current installation docs, Redis Open Source licensing and the Valkey compatibility context.
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.
The current official installation path changed
Redis now recommends Docker for the fastest start, official APT/RPM packages on Linux, the Redis Homebrew tap on macOS and Docker on Windows.
Redis 8, licensing and Valkey matter before production
Redis 8 includes AGPLv3 as part of its tri-license and integrates Redis Stack-era features, while Valkey remains an important Redis OSS 7.2 compatible option.
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.
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.
The 2026 context adds two decisions before production: Redis 8 now includes technologies that used to be associated with Redis Stack, such as JSON, search/query, time series and probabilistic structures, and the Redis/Valkey split means you should check licensing, managed-service compatibility and client support before choosing a platform.
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.
Redis 8 and Valkey
Redis 8 is available under a tri-license that includes AGPLv3, while Valkey keeps compatibility with Redis OSS 7.2 and earlier. For much application code the command model feels familiar, but production choices now include legal, hosting and compatibility checks.
Install with Homebrew
brew tap redis/redis
brew install --cask redis
redis-server $(brew --prefix)/etc/redis.conf
redis-cli pingThe current Redis docs use the official Homebrew tap and cask. After starting the server, `redis-cli ping` should answer `PONG`.
Use the official Redis packages
sudo apt-get install lsb-release curl gpg
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
sudo apt-get update
sudo apt-get install redis
redis-cli pingOn Debian or Ubuntu, prefer the official Redis repository when you want current Redis Open Source packages instead of older distribution builds.
Run Redis with Docker
docker run -d --name redis -p 6379:6379 redis
redis-cli -h localhost -p 6379 pingThe current Redis docs present Docker as the Windows path. Memurai appears as a preview compatibility route for Redis Open Source 8.2 RC1, so Docker is the safer general recommendation for development.
Compile Redis manually
wget https://download.redis.io/redis-stable.tar.gz
tar -xzvf redis-stable.tar.gz
cd redis-stable
make
sudo make installThis route is useful when you want more control, need to test source builds or work on environments where packages are not enough.
Basic commands with redis-cli
redis-cli ping
SET site:name "1938"
GET site:name
DEL site:nameThis is the minimal loop: verify the server, write a key, read it and delete it.
Store data with expiration
SET page:home "<html>...</html>" EX 60
TTL page:home
GET page:homeThis 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.
Count requests or events
INCR stats:visits
INCRBY stats:api:requests 5
GET stats:visitsCounters are trivial in Redis and are frequently used for analytics, quotas and lightweight monitoring.
Represent a small user object
HSET user:42 name "Ana" role "admin" plan "pro"
HGET user:42 name
HGETALL user:42Hashes are useful when several fields belong to the same key and you do not need a full relational record with joins.
Simple queue example
LPUSH queue:emails "send-welcome:42"
LPUSH queue:emails "send-reset:18"
RPOP queue:emailsA list is enough for many simple queue scenarios, especially in internal tools or small background jobs.
Basic rate limiting by IP
MULTI
INCR rate:ip:203.0.113.10
EXPIRE rate:ip:203.0.113.10 60
EXECThe 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.
Official references
Redis Open Source installation
Redis licenses
Redis vector search
Valkey migration and compatibility
Redis 8, search and vector features
Redis can now cover more than a simple cache: Redis Open Source documentation includes Redis Query Engine, JSON, vector search and AI/search use cases. That is useful for semantic search, metadata filtering and fast retrieval, but it does not remove the need to model memory limits, durability and the role of your primary database.
Licensing and managed services
Redis 8 and later are offered under RSALv2, SSPLv1 or AGPLv3; Redis 7.2 and earlier remain BSD-3-Clause. Valkey is relevant when you need Redis OSS 7.2 compatibility under a different project and ecosystem. For company projects, verify this with legal and with the managed provider you plan to use.
Persistence decision
Before using Redis as more than a cache, decide whether losing recent writes is acceptable. RDB snapshots, AOF and managed Redis services have different trade-offs between speed, durability and operational complexity.
Eviction and memory
Redis is fast because memory is the main resource. Configure maxmemory and an eviction policy intentionally; otherwise the first serious traffic spike can become a production incident instead of a performance improvement.
Related database reads
Next database reads
If Redis is already clear, the next useful step is to compare it with document, wide-column or graph databases depending on your real use case.