skillfed

redis

This skill walks you through deploying and operating Redis across single-instance, Sentinel, and cluster modes. Learn core commands for strings, hashes, lists, and sorted sets; configure persistence with RDB snapshots and AOF; implement caching, rate limiting, pub/sub, and distributed locking patterns; and run Redis in Docker with monitoring.

Redis helps you set up in-memory caching, queues, and data storage with clustering and failover.

AI-generated summary based on this skill's SKILL.md

44 4 MIT updated by BagelHole

Install

BagelHole/DevOps-Security-Agent-Skills/redis · repository language: Shell

git clone https://github.com/BagelHole/DevOps-Security-Agent-Skills
cp -r DevOps-Security-Agent-Skills/infrastructure/databases/redis ~/.claude/skills/redis
npx skillfed install BagelHole/DevOps-Security-Agent-Skills/redis

Frequently asked questions

AI-generated answers based on this skill's SKILL.md and metadata

How to set up Redis caching for my application?

Redis caching setup begins with installation and basic configuration. Start by installing Redis, then configure your redis.conf file with memory limits, eviction policies, and bind addresses. Redis provides string, hash, list, and sorted set data types optimized for fast lookups. Use SET/GET commands for simple caching, or HSET/HGET for structured data. For production, run Redis in Docker using a docker-compose.yml file that exposes port 6379 and mounts a persistent volume. Configure maxmemory and maxmemory-policy (e.g., allkeys-lru) to handle memory constraints automatically.

What are Redis persistence RDB and AOF options?

Redis offers two persistence mechanisms. RDB (Redis Database) creates point-in-time snapshots at intervals you specify—fast to load but may lose recent data if Redis crashes. AOF (Append-Only File) logs every write command, providing better durability but slower performance and larger disk usage. Redis persistence configuration lets you combine both: RDB for recovery speed and AOF for safety. Configure save directives (e.g., 'save 900 1') and appendonly yes in redis.conf. Choose based on your tolerance for data loss versus performance requirements.

How do I configure Redis for high availability?

Redis high availability uses Sentinel or Cluster modes. Sentinel monitors master-replica replication and automatically promotes a replica to master on failure—ideal for simpler setups. Configure multiple Sentinel instances (minimum 3) pointing to your master Redis instance. Cluster mode shards data across nodes, distributing load and storage. For Sentinel failover setup, define sentinel.conf with monitor directives and quorum settings. Both modes require careful network configuration and monitoring to detect and respond to failures automatically.

What is distributed locking with Redis and how is it used?

Redis distributed locking coordinates access to shared resources across multiple processes or servers. Implement it using SET with NX (only if not exists) and EX (expiration) flags: SET key value NX EX seconds. This ensures atomic lock acquisition and automatic release if the process crashes. Use Lua scripts for complex lock logic. Distributed locking enables rate limiting, preventing duplicate job processing in queues, and coordinating cache updates. Always set reasonable TTLs to avoid deadlocks.

How can I monitor Redis performance and troubleshoot OOM errors?

Redis performance monitoring uses INFO command to check memory usage, connected clients, and command statistics. Watch for OOM (Out of Memory) errors by tracking used_memory against maxmemory. Use MONITOR to see real-time commands, or enable slow log with slowlog-log-slower-than. Troubleshoot OOM by reducing maxmemory, adjusting eviction policies (allkeys-lru evicts least-recently-used keys), or scaling to cluster mode. Docker environments require explicit memory limits in compose files. Regular monitoring prevents crashes and identifies bottlenecks.

Can Redis implement pub/sub messaging and queue patterns?

Redis pub/sub enables real-time message broadcasting: PUBLISH sends messages to channels, SUBSCRIBE listens for them. However, pub/sub doesn't persist messages—subscribers must be connected. For durable queues, use lists with LPUSH/RPOP or BLPOP (blocking pop). Redis queues handle job processing, task distribution, and rate limiting. Combine queues with distributed locking for exactly-once processing. Pub/sub suits live notifications; queues suit reliable job execution. Both patterns integrate seamlessly into Redis applications.

SKILL.md

rendered from the published skill — quoted content, verbatim

Redis

Configure, operate, and optimize Redis for caching, queues, rate limiting, and real-time data storage.

When to Use

  • You need a low-latency in-memory cache to reduce database load.
  • Your application requires rate limiting, session storage, or leaderboards.
  • You need pub/sub messaging between services.
  • You want a distributed lock or job queue backed by an in-memory store.

Prerequisites

  • Linux server or Docker.
  • Root or sudo access for package installation.
  • Redis 7.x recommended for production.

Installation and Setup

# Debian / Ubuntu
sudo apt update
sudo apt install -y redis-server

# RHEL / Amazon Linux
sudo dnf install -y redis

# Start and enable
sudo systemctl enable --now redis-server

# Verify
redis-cli ping
# Expected output: PONG

Core Configuration

Edit /etc/redis/redis.conf:

```ini

Network

bind 0.0.0.0 port 6379 protected-mode yes requirepass strong_redis_password

Memory

maxmemory

(truncated - see the full file via the links below)

Read as markdown · JSON record · Browse the source repository

File tree — 1 file
infrastructure/databases/redis/SKILL.md

Related skills

Tags

in-memory-database distributed-caching high-availability data-persistence message-queue session-management failover-automation performance-optimization cluster-sharding real-time-storage