jyasuu

redis

Redis in-memory data structure store commands including key operations, hashes, pub/sub, streams, and clustering.

jyasuu 0 Updated 4mo ago
GitHub

Install

npx skillscat add jyasuu/cheat-sheet/redis

Install via the SkillsCat registry.

SKILL.md

Redis — Key Operations

Basic Commands

redis-cli
SET key "value"
GET key
DEL key
EXPIRE key 60  # TTL in seconds

Hashes

HSET user:1000 name "John" age 30
HGETALL user:1000

Publish/Subscribe

# Terminal 1:
SUBSCRIBE channel

# Terminal 2:
PUBLISH channel "message"

Redis — Advanced Patterns

Streams

# Producer:
XADD mystream * sensor-id 1234 temp 19.8

# Consumer:
XREAD BLOCK 0 STREAMS mystream $

Lua Scripting

eval "return redis.call('GET', KEYS[1])..ARGV[1]" 1 mykey _suffix

Cluster Management

redis-cli --cluster create 127.0.0.1:7000 127.0.0.1:7001
redis-cli --cluster check 127.0.0.1:7000