Ch 2 · Redis Introduction and Setup · Redis

Topic 2 of 5 in Redis — Complete Tutorial (Beginner) — 4 lessons.

What is Redis?

Get started with Redis: understand in-memory data storage and basic commands. Because Redis keeps its data in RAM, reads and writes are extremely fast, which is why it is popular for caching and sessions. You will learn how keys map to values, how SET and GET store and fetch a string, and how EX makes a key expire automatically.

Redis in Code

This example connects to Redis with the ioredis library and runs the everyday string commands. Follow how SET stores a greeting and GET reads it back, then how adding EX with 3600 gives a session key a one-hour lifespan. Look at what TTL reports, and notice that after DEL removes the key, EXISTS returns 0.

Practice: What is Redis?

Time to try the basics yourself. You will connect to Redis, store a value under a key, read it back and print it, then save a second key that expires and check how long it has left. A correct answer proves you understand the difference between a permanent key and one with a time-to-live, and what TTL tells you about each.

Solution & Challenge: What is Redis?

Check your work against the worked solution, which sets and reads a name, stores a token that expires after 300 seconds, then deletes a key and confirms it has gone. The challenge asks you to build a small command-line key-value store that understands SET, GET, DEL and TTL, lists keys with SCAN rather than KEYS, and handles errors such as a missing key gracefully.

All topics in Redis Beginner

  1. Redis Hashes
  2. Redis Introduction and Setup
  3. Redis Lists
  4. Redis Sets
  5. Redis Strings and Numbers