Back to list
doanchienthangdev

developing-with-redis

by doanchienthangdev

Omega Vibecode Kit

2🍴 1📅 Jan 21, 2026

SKILL.md


name: Developing with Redis description: The agent implements Redis caching, data structures, and real-time messaging patterns. Use when implementing caching layers, session storage, rate limiting, pub/sub messaging, or distributed data structures.

Developing with Redis

Quick Start

import Redis from 'ioredis';

const redis = new Redis({
  host: process.env.REDIS_HOST || 'localhost',
  port: parseInt(process.env.REDIS_PORT || '6379'),
  maxRetriesPerRequest: 3,
});

// Basic caching
await redis.setex('user:123', 3600, JSON.stringify(userData));
const cached = await redis.get('user:123');

Features

FeatureDescriptionGuide
CachingHigh-speed key-value storage with TTLUse setex for auto-expiration, get for retrieval
Session StorageDistributed session managementStore sessions with user ID index for multi-device
Rate LimitingRequest throttling with sliding windowsUse sorted sets or token bucket algorithms
Pub/SubReal-time messaging between servicesSeparate subscriber connections from publishers
StreamsEvent sourcing and message queuesConsumer groups for reliable message processing
Data StructuresLists, sets, sorted sets, hashesChoose structure based on access patterns

Common Patterns

Cache-Aside Pattern

async function getOrSet<T>(key: string, factory: () => Promise<T>, ttl = 3600): Promise<T> {
  const cached = await redis.get(key);
  if (cached) return JSON.parse(cached);

  const value = await factory();
  await redis.setex(key, ttl, JSON.stringify(value));
  return value;
}

Sliding Window Rate Limiter

async function checkRateLimit(key: string, limit: number, windowSec: number): Promise<boolean> {
  const now = Date.now();
  const windowStart = now - windowSec * 1000;

  const pipeline = redis.pipeline();
  pipeline.zremrangebyscore(key, '-inf', windowStart);
  pipeline.zadd(key, now, `${now}:${Math.random()}`);
  pipeline.zcard(key);
  pipeline.expire(key, windowSec);

  const results = await pipeline.exec();
  const count = results?.[2]?.[1] as number;
  return count <= limit;
}

Distributed Lock

async function acquireLock(key: string, ttlMs = 10000): Promise<string | null> {
  const lockId = crypto.randomUUID();
  const acquired = await redis.set(`lock:${key}`, lockId, 'PX', ttlMs, 'NX');
  return acquired === 'OK' ? lockId : null;
}

async function releaseLock(key: string, lockId: string): Promise<boolean> {
  const script = `if redis.call("get",KEYS[1])==ARGV[1] then return redis.call("del",KEYS[1]) else return 0 end`;
  return (await redis.eval(script, 1, `lock:${key}`, lockId)) === 1;
}

Best Practices

DoAvoid
Set TTL on all cache keysStoring objects larger than 100KB
Use pipelines for batch operationsUsing KEYS command in production
Implement connection poolingIgnoring memory limits and eviction
Use Lua scripts for atomic operationsUsing Redis as primary database
Add key prefixes for namespacingBlocking on long-running operations
Monitor memory with INFO memoryStoring sensitive data unencrypted
Set up Redis Sentinel for HASkipping connection error handling

Score

Total Score

60/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon