스킬 redis-patterns

redis-patterns

안전 🌐 네트워크 접근⚙️ 외부 명령어🔑 환경 변수

實作 Redis 快取與速率限制

應用程式需要高效的快取機制和防濫用措施,但缺乏明確的實作模式。本技能提供生產環境可用的 Upstash Redis 模式,適用於快取、速率限制、工作階段儲存和發布/訂閱訊息傳遞。

지원: Claude Codex Code(CC)
⚠️ 68 나쁨
1

스킬 ZIP 다운로드

2

Claude에서 업로드

설정 → 기능 → 스킬 → 스킬 업로드로 이동

3

토글을 켜고 사용 시작

테스트해 보기

"redis-patterns" 사용 중입니다. How do I cache user data with Redis?

예상 결과:

  • Check cache first using redis.get(key)
  • If cached, return cached data
  • If not cached, fetch from database
  • Store result in Redis with setex(key, ttl, value)
  • Return the data
  • Key pattern: user:{id} for easy invalidation

"redis-patterns" 사용 중입니다. I need to limit API requests per user

예상 결과:

  • Create a Ratelimit instance with sliding window
  • Pass unique identifier (IP or userId) to limit function
  • Check success boolean in response
  • Return 429 status with headers when limit exceeded
  • Include X-RateLimit headers for client awareness

"redis-patterns" 사용 중입니다. How do I invalidate cached data?

예상 결과:

  • Use redis.del(key) for single key removal
  • Delete all related cache keys when data updates
  • Consider cache versioning for complex invalidation
  • Use TTL as fallback for automatic expiration

보안 감사

안전
v5 • 1/16/2026

This skill contains only markdown documentation with code examples. No executable code, no file system access, no network calls, and no external command execution. The static scanner flagged standard patterns as threats: JavaScript template literals (misidentified as shell backticks), process.env configuration (misidentified as credential access), and crypto.randomUUID (misidentified as weak crypto). All findings are false positives. This is purely instructional material for Redis patterns.

2
스캔된 파일
354
분석된 줄 수
3
발견 사항
5
총 감사 수
감사자: claude 감사 이력 보기 →

품질 점수

38
아키텍처
100
유지보수성
85
콘텐츠
21
커뮤니티
100
보안
83
사양 준수

만들 수 있는 것

快取資料庫查詢

透過自動到期和失效機制快取頻繁查詢,以減少資料庫負載。

防止 API 濫用

實作速率限制以保護端點免受過多請求和 DDoS 攻擊。

管理使用者工作階段

為使用者驗證系統安全地儲存工作階段資料,並具有自動到期功能。

이 프롬프트를 사용해 보세요

基本快取
Show me how to cache a database query result in Upstash Redis with a 5-minute TTL. Include cache-aside pattern.
速率限制
Implement rate limiting for an API route using @upstash/ratelimit. Allow 10 requests per 10 seconds per IP.
工作階段儲存
Create session storage functions using Upstash Redis. Include create, get, and delete operations with 7-day expiration.
即時事件
Show how to use Redis pub/sub for real-time event publishing. Include publisher and subscriber examples.

모범 사례

  • 使用描述性的鍵前綴(user:、session:、cache:)來組織資料
  • 當底層資料變更時,永遠使相關快取失效
  • 根據資料新鮮度要求設定適當的 TTL 值
  • 使用 redis.del() 進行快取失效,而非等待 TTL 到期

피하기

  • 在 Redis 中儲存敏感資料而不進行加密
  • 使用極長的 TTL 阻止資料更新傳播
  • 不快處理快取未命中,沒有回退到資料庫
  • 儲存整個大型物件而非參照它們

자주 묻는 질문

Upstash Redis 與標準 Redis 用戶端相容嗎?
Upstash 提供 REST API 並與 @upstash/redis SDK 相容。部分標準 Redis 用戶端可能無法完全相容。
Upstash Redis 的最大 TTL 是多少?
Upstash Redis 支援最多 30 天 TTL 的大多數操作。若需要更長的持續時間,請實作定期重新整理邏輯。
此技能可以與現有的 Redis 安裝整合嗎?
這些模式使用專為 Upstash 伺服器端 Redis 設計的 @upstash/redis。標準 Redis 需要不同的設定。
我的資料在 Upstash Redis 中安全嗎?
Upstash 提供靜態和傳輸中加密。請使用環境變數來儲存憑證,避免將密鑰直接寫入程式碼。
為什麼我的速率限制無法正確運作?
確保傳遞唯一的識別符(IP 或使用者 ID)到限制函數。檢查速率限制器是否已全域實例化一次。
這與直接使用 Redis 相比如何?
Upstash 提供無伺服器定價和更簡單的設定,但對 API 呼叫有速率限制。標準 Redis 提供更多控制,但需要伺服器管理。

개발자 세부 정보

파일 구조

📄 SKILL.md