CLI Basics and Core Commands

Harry · 13 Sep 2026 · 1 views

Strings

SET greeting "hello"
GET greeting
SET counter 0
INCR counter          # 1
INCRBY counter 5      # 6
SETEX key 60 value    # set with 60s TTL

Keys and Expiry

KEYS *                # list keys (avoid in production)
EXISTS greeting       # 1
TTL key               # seconds until expiry
EXPIRE greeting 120
DEL greeting

Generic Utilities

TYPE key              # string/list/set/hash/zset/stream
RENAME old new
SELECT 1              # switch database
FLUSHDB               # clear current database only

Instrumentation

INFO
MONITOR               # log every command (dev only)
CONFIG GET maxmemory

Key Points

  • Strings plus INCR/EXPIRE cover counters and caches.
  • TTL and KEYS shape retention and admin.
  • SELECT switches logical databases.
  • MONITOR is a debugger, never run it in prod traffic.
Share this post:

Comments (0)

Please login or register to comment.