0Pricing
Redis Caching & Messaging (Pub/Sub, Streams) · Lesson

Redis CLI Basics

Learn to connect to Redis, execute basic commands, and manage data via the command-line interface.

Redis CLI Basics is a free Redis Caching & Messaging (Pub/Sub, Streams) lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Redis Caching & Messaging (Pub/Sub, Streams) learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

What is Redis CLI?

The redis-cli lets you talk to your Redis server directly — perfect for quick tests, debugging, and admin without writing any app code.

Connecting to Redis

Connect by running redis-cli in your terminal. It defaults to 127.0.0.1 on port 6379 and drops you at a prompt ready for commands.

Your First Command: PING

PING checks that the server is alive — type it and a healthy Redis replies PONG. Your simplest health check.

Storing Data: SET

SET stores a string value under a key: SET key value. Like sticking a labeled note on the fridge — the example shows it returning OK.

Retrieving Data: GET

GET retrieves a key's value: GET key. If the key doesn't exist, Redis returns (nil) instead.

Updating Values

Run SET on an existing key and it overwrites the old value — no confirmation prompt, so be careful. The example shows the value getting replaced.

Deleting Data: DEL

DEL removes one or more keys: DEL key [key ...]. It returns how many keys were actually deleted.

Checking Key Existence: EXISTS

EXISTS tells you if a key is present without fetching its value — returning 1 if it exists, 0 if not.

Counting with INCR & DECR

Redis does counters: INCR bumps a key's integer up by one, DECR drops it by one. A missing key starts at 0 before the operation.

CLI Command Challenge

What will be the final value of the key mycounter after executing these Redis CLI commands?

SET mycounter 5
INCR mycounter
DECR mycounter
INCR mycounter
DEL mycounter
INCR mycounter

Recap: Redis CLI Basics

Recap: with the redis-cli you can connect, PING, SET and GET strings, overwrite keys, DEL them, check EXISTS, and run INCR/DECR counters.

Frequently asked questions

Is the “Redis CLI Basics” lesson free?

Yes — the full text of “Redis CLI Basics” is free to read here on the web, and the Redis Caching & Messaging (Pub/Sub, Streams) course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Redis Caching & Messaging (Pub/Sub, Streams) course, upgrade to CoddyKit PRO.

What will I learn in “Redis CLI Basics”?

Learn to connect to Redis, execute basic commands, and manage data via the command-line interface. You practise Redis Caching & Messaging (Pub/Sub, Streams) with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Redis Caching & Messaging (Pub/Sub, Streams)?

No prior experience is required. Redis Caching & Messaging (Pub/Sub, Streams) on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Redis CLI Basics” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Redis Caching & Messaging (Pub/Sub, Streams) lesson?

Yes. Every Redis Caching & Messaging (Pub/Sub, Streams) lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Introduction to Redis
  2. Redis CLI Basics
  3. Core Redis Data Structures
  4. Key Expiration and TTL in Redis
← Back to Redis Caching & Messaging (Pub/Sub, Streams)