Skip to main content

Redis

Remote Dictionary Server

Pronunciation
RED-iss
Updated 2 min read

Share this page

Send the link, quote the definition with a link back, or show it as a card on your own site.

https://softwaredictionary.org/terms/redis

In short

Redis is an in-memory key-value store that reads and writes in well under a millisecond, which makes it a popular cache, session store and message broker.

What is Redis?

Redis, short for Remote Dictionary Server, was created by Salvatore Sanfilippo in 2009. It stores data as keys and values, like a giant dictionary, but the values can be rich data structures: strings, lists, sets, sorted sets, hashes, streams and more. Because everything lives in memory instead of on disk, most operations finish in microseconds.

Applications talk to Redis with simple commands such as SET, GET, INCR or EXPIRE. A key can be given a time to live, after which Redis deletes it on its own, which is exactly what a cache or a login session needs. Redis can also save snapshots or an append-only log to disk, so data survives a restart, and it can replicate to other servers for high availability.

Typical uses are caching database results, storing user sessions, counting things such as page views or rate-limit hits, leaderboards built on sorted sets, and lightweight queues or pub/sub messaging between services. In many systems it sits next to a main database like PostgreSQL, holding the hot data that is read again and again.

A common misconception is that Redis is only a cache. It is a full data store, but its data must fit in memory, which is more expensive than disk, so it is rarely the only database an application has. Since 2024 its license has changed more than once, and the Linux Foundation maintains an open-source fork called Valkey that works with the same commands.

At a glance

Caching with Redis, the cache-aside pattern. The app asks Redis for user:42 and gets nothing back, a miss, so it queries the database, which is slower, and then stores the row in Redis for 60 seconds. On the next request, Redis answers straight from memory, a hit, and the database isn't asked at all.AppRedisDatabaseFirst requestGET user:42(nil): a missSELECT … WHERE id = 42row, after a few msSET user:42 … EX 60Next request, within 60 sGET user:42the cached row, in under 1 msnot asked
The first request pays for the database; every request in the next 60 seconds is answered from memory, and the key then expires on its own.

Key takeaways

  • Redis is an in-memory key-value store, so reads and writes are extremely fast.
  • Values can be strings, lists, sets, sorted sets, hashes and streams.
  • Keys can expire automatically, which suits caches and sessions.
  • Data can be saved to disk and replicated to other servers.
  • It usually works next to a main database rather than replacing it.

Example

Caching a value for one minute (Node.js)javascript
import { createClient } from "redis";

const redis = createClient();
await redis.connect();

// Store a value that Redis deletes after 60 seconds
await redis.set("user:42:name", "Ada", { EX: 60 });

const name = await redis.get("user:42:name"); // "Ada"
await redis.incr("page:home:views"); // atomic counter

Readers ask

Is Redis a database or a cache?

Both. Redis is a data store that can keep data permanently, but because its data lives in memory it is most often used as a cache or for short-lived data next to a main database.

What happens to Redis data when the server restarts?

Without persistence it is lost. With snapshots (RDB) or an append-only file (AOF) turned on, Redis reloads the data from disk when it starts again.

What is Valkey?

Valkey is an open-source fork of Redis maintained under the Linux Foundation, started in 2024 after Redis changed its license. It works with the same commands and client libraries.

See also

Sources

Spotted a mistake or something missing on this page?Suggest an edit

Read a random page
Open today's review
Switch to the dark theme
Read this page in Türkçe

More

Settings