Skip to content
BENIBIX Learn

Redis

Development🗃️ DatabasesNoSQL Databases

Also known as Redis Database

A store that keeps data in memory, under keys. That makes it very fast.

Think of it like

Think of it like a sticky note on your desk, not a file down in the cellar. It is right there when you need it.

Example

Jack's shop caches its home page product list in Redis for 60 seconds. The main database gets one query a minute instead of thousands.

Why it matters

Reading from memory is far faster than from disk. Redis takes load off the main database.

Definition

Redis is a key-value store that keeps data in memory. That makes it very fast. It can hold plain text, lists, sets and counters under each key. Keys can be told to expire after a set time. Most apps use it as a cache or a session store in front of a main database. Its server listens on port 6379 by default.

Example code

console
$ redis-cli SET greeting "Hi Emma"
OK
$ redis-cli GET greeting
"Hi Emma"
Save a value under a key, then read it back.

Common mistake

Treating it as the only copy of important data. If it is set up as a cache, a restart can lose what it holds.

Key takeaways

  1. 1
    In memory. Extremely fast reads and writes.
  2. 2
    Keys can expire. Old data clears itself.
  3. 3
    In front of the database. A cache, not the main store.