Redis
Key-value storage, data types, caching and configuration.
Level 101 · 16 lessons · 15 practice labs
Lessons
Getting started
- Install and redis-cli: You will install Redis on your own lab machine and connect to the server with redis-cli to run your first commands.
- Where Redis is used: caches, counters and queues
- Redis strings and keys: SET, GET, EXISTS, DEL: You will write a value to a key in Redis, read it, check whether it exists and delete it.
- Redis key naming, TYPE and SCAN: You will name keys consistently, ask for their type and scan them safely with SCAN instead of KEYS.
- Redis key expiration: You will give a Redis key a lifetime so it deletes itself after a set time, and see how much time is left.
- Redis counters: INCR, DECR: You will raise and lower counters safely in Redis with INCR and DECR and learn where counters are used.
- Short task: a page visit counter with expiry
Data types
- Redis lists: You will push items onto Redis lists from either end, pop them off and use a list like a queue.
- Redis sets: You will keep unique items in Redis sets and compare two sets with each other.
- Redis hashes: You will hold several fields of one object under a single Redis key in a hash and read each field separately.
- Redis sorted sets: You will use Redis sorted sets, where each item has a score, and list the highest or lowest items.
- Short task: a shop’s cart and ranking data
Configuration and operation
- Redis configuration and the memory limit: You will read the Redis configuration and understand the setting that decides what happens when the memory limit fills up.
- Redis persistence and security settings: You will learn how data is saved to disk and how to keep Redis open only to those who need it, using a password and network settings.
- Looking at the server with INFO and MONITOR
- Capstone: a cache layer with Redis: You build a simple cache layer that stores the result of a fictional company's slow query in Redis for a limited time.
Practice labs
- Store product names as keys: Write a café menu with tidy key names using SET and read it back with GET.
- Scan keys with SCAN instead of KEYS: On a server with millions of keys, find and count matching keys with SCAN without blocking it.
- Bring order to messy key names: Inventory keys created in different styles by different teams, with their types, and move them to a shared naming scheme.
- Store a verification code for 5 minutes: Store a phone verification code as an expiring key and watch it disappear with TTL.
- Build a daily visit counter: Create INCR-based visit counters per page that delete themselves at the end of the day.
- Find why keys lose their expiry: Some cache keys never expire; find which commands reset the TTL and fix the code.
- Keep the last 10 searches in a list: Keep a user's latest searches with LPUSH and LTRIM so the list never exceeds 10 items.
- Find shared interests with an intersection: Produce suggestions by intersecting and diffing the tag sets two members follow.
- Block duplicate notifications with a set: Build a set-based check, cleared daily, that stops the same event being notified more than once.
- Store a cart as a hash: Keep a customer's cart in a hash keyed by product code, increase quantities and count items.
- Show the top 10 sellers with a sorted set: Build a sorted set whose score grows with each sale and list the top 10 sellers with scores.
- Merge period rankings: Merge weekly sorted sets into a monthly ranking with ZUNIONSTORE and expire old weeks.
- Read the server's memory use: Find used memory, peak and the memory limit in INFO memory output.
- Set a memory limit and eviction policy: Give a cache server a memory limit and suitable eviction policy, then fill it and watch the behaviour.
- Catch wasteful commands with MONITOR: Use a short MONITOR capture to find the app reading the same key over and over and propose a fix.
About this course
Key-value storage, data types, caching and configuration.
What you will learn
- Getting started
- Data types
- Configuration and operation
Prerequisites
No prior knowledge is needed; the course starts from zero.
Lab environment
Lessons run in your own Kali Linux terminal in the browser, connected to a private lab network. Nothing to install.
Frequently asked questions
- Is this course right for my level?
- The course is at beginner level; every term is explained where it first appears.
- Is there anything to install?
- No. Every lesson runs in your own lab environment that opens in the browser.
- How do lessons work?
- Each lesson has 8 to 10 steps and a short quiz. Early steps show the command to type, later steps give less help; if two attempts fail, the solution opens.
- Can I try it for free?
- Yes. The first three lessons of every course are free.