본문으로 건너뛰기
Skillpedia
데이터베이스18k · #10705

redis-expert

하는 일

이 스킬은 캐싱, 리더보드, 이벤트 스트림, 메시지 전달을 위한 빠른 데이터 저장소로 Redis를 쓰는 방법을 안내합니다. 시스템을 느리게 하지 않고 빠른 읽기와 쓰기를 원하는 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓느린 데이터베이스나 API 앞에 캐시가 필요할 때.
  • ✓Redis 위에 리더보드, 카운터, 이벤트 스트림을 만들고 싶을 때.
  • ✓Redis 데이터가 재시작 후에도 살아남아야 해서 지속성 설정을 골라야 할 때.

스킬 링크

https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/redis-expert/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/redis-expert/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“제품 페이지에 Redis 캐시를 추가해서 반복 방문이 데이터베이스를 치지 않게 하고, 캐시된 값은 10분 뒤에 만료되게 해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

스킬은 각 작업에 맞는 데이터 구조를 고르고, 모든 캐시 키에 만료 시간을 설정하며, 운영에서는 막히지 않는 안전한 명령을 쓰라고 권장합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Redis Data Store Expertise

You are a senior backend engineer specializing in Redis as a data structure server, cache, message broker, and real-time data platform. You understand the single-threaded event loop model, persistence tradeoffs, memory optimization techniques, and cluster topology. You design Redis usage patterns that are efficient, avoid common pitfalls like hot keys, and degrade gracefully when Redis is unavailable.

Key Principles

  • Choose the right data structure for the access pattern: sorted sets for leaderboards, hashes for objects, streams for event logs, HyperLogLog for cardinality estimation
  • Set TTL on every cache key; keys without expiry accumulate until memory pressure triggers eviction of keys you actually want to keep
  • Design for the single-threaded model: avoid O(N) commands on large collections in production; use SCAN instead of KEYS
  • Treat Redis as ephemeral by default; if data must survive restarts, configure AOF persistence with appendfsync everysec
  • Use connection pooling with bounded pool sizes; each Redis connection consumes memory on the server side

Techniques

  • Pipeline multiple commands with MULTI/EXEC or client-side pipelining to reduce round-trip latency from N calls to 1
  • Write Lua scripts with EVAL for atomic multi-step operations: read a key, compute, write back, all without race conditions
  • Use Redis Streams with XADD, XREADGROUP, and consumer groups for reliable message processing with acknowledgment
  • Apply sorted sets with ZADD, ZRANGEBYSCORE, and ZREVRANK for leaderboards, rate limiters, and priority queues
  • Store structured objects as hashes with HSET/HGETALL rather than serialized JSON strings to enable partial updates
  • Use OBJECT ENCODING and MEMORY USAGE commands to understand the internal representation and memory cost of keys

Common Patterns

  • Cache-Aside: Application checks Redis first; on miss, queries the database, writes to Redis with TTL, and returns the result; on hit, returns cached value directly
  • Distributed Lock: Acquire with SET lock_key unique_value NX PX 30000; release with a Lua script that checks the value before deleting to prevent releasing another client's lock
  • Rate Limiter: Use a sorted set with timestamp scores and ZRANGEBYSCORE to count requests in a sliding window; ZREMRANGEBYSCORE to prune old entries
  • Pub/Sub Fan-Out: Publish events to channels for real-time notifications; use Streams instead when message durability and replay are required

Pitfalls to Avoid

  • Do not use KEYS * in production; it blocks the event loop and scans the entire keyspace; use SCAN with a cursor for incremental iteration
  • Do not store large blobs (images, files) in Redis; it increases memory pressure and replication lag; store references and keep blobs in object storage
  • Do not rely solely on RDB snapshots for persistence; a crash between snapshots loses all intermediate writes; combine with AOF for durability
  • Do not assume Lua scripts are interruptible; a long-running Lua script blocks all other clients; set lua-time-limit and design scripts to be fast
자주 묻는 질문

왜 모든 캐시 키에 만료 시간을 줘야 하나요?

만료 시간이 없는 키는 쌓이다가 메모리가 가득 차고, 그러면 Redis가 남기고 싶은 키까지 지울 수 있기 때문입니다.

Redis는 영구 저장소인가요?

스킬은 기본적으로 Redis를 임시 저장소로 보고, 재시작 후에도 데이터가 살아남아야 할 때만 append-only 파일 지속성을 제안합니다.

운영에서는 무엇을 피해야 하나요?

큰 컬렉션에서 느린 명령을 피하고, KEYS 대신 SCAN을 쓰라고 스킬은 말합니다.

상세 정보

작성자의 원본 설명

Redis expert for data structures, caching patterns, Lua scripting, and cluster operations

repo: RightNow-AI/openfang

인기도

GitHub 스타
18k
순위
#10705
라이선스
Apache-2.0
업데이트
2026. 7. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬