Loading skill
Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Upstash Redis patterns for caching and rate limiting.
.claude/skills/aiskillstore-redis-patterns/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-05 | ✗→✓ | ▲ Improved | 28% | 0% |
| case-04 | ✗→✓ | ▲ Improved | -6% | 0% |
| case-06 | ✗→✓ | ▲ Improved | -27% | 0% |
| case-08 | ✗→✓ | ▲ Improved | -17% | 0% |
| case-15 | ✗→✓ | ▲ Improved | -14% | 0% |
typescript// lib/redis.ts import { Redis } from '@upstash/redis'; export const redis = new Redis({ url: process.env.UPSTASH_REDIS_REST_URL!, token: process.env.UPSTASH_REDIS_REST_TOKEN!, });
typescript// Cache with TTL async function getCachedUser(id: string): Promise<User | null> { const cacheKey = `user:${id}`; // Try cache first const cached = await redis.get<User>(cacheKey); if (cached) return cached; // Fetch from DB const user = await db.query.users.findFirst({ where: eq(users.id, id), }); if (user) { // Cache for 5 minutes await redis.setex(cacheKey, 300, user); } return user; }
typescript// Invalidate on update async function updateUser(id: string, data: UpdateUserInput): Promise<User> { const user = await db.update(users) .set(data) .where(eq(users.id, id)) .returning(); // Invalidate cache await redis.del(`user:${id}`); // Also invalidate list caches await redis.del('users:list'); return user[0]; }
typescriptimport { Ratelimit } from '@upstash/ratelimit'; const ratelimit = new Ratelimit({ redis, limiter: Ratelimit.slidingWindow(10, '10 s'), // 10 requests per 10 seconds analytics: true, }); // In API route or middleware export async function POST(request: Request) { const ip = request.headers.get('x-forwarded-for') ?? 'anonymous'; const { success, limit, reset, remaining } = await ratelimit.limit(ip); if (!success) { return new Response('Too Many Requests', { status: 429, headers: { 'X-RateLimit-Limit': limit.toString(), 'X-RateLimit-Remaining': remaining.toString(), 'X-RateLimit-Reset': reset.toString(), }, }); } // Process request... }
typescriptinterface Session { userId: string; expiresAt: number; } async function createSession(userId: string): Promise<string> { const sessionId = crypto.randomUUID(); const session: Session = { userId, expiresAt: Date.now() + 7 * 24 * 60 * 60 * 1000, // 7 days }; await redis.setex(`session:${sessionId}`, 7 * 24 * 60 * 60, session); return sessionId; } async function getSession(sessionId: string): Promise<Session | null> { return await redis.get<Session>(`session:${sessionId}`); } async function deleteSession(sessionId: string): Promise<void> { await redis.del(`session:${sessionId}`); }
typescript// Publisher async function publishEvent(channel: string, data: unknown): Promise<void> { await redis.publish(channel, JSON.stringify(data)); } // Usage await publishEvent('user:updates', { userId: '123', action: 'updated' });
typescript// Add score await redis.zadd('leaderboard', { score: 100, member: 'user:123' }); // Get top 10 const topUsers = await redis.zrevrange('leaderboard', 0, 9, { withScores: true }); // Get user rank const rank = await redis.zrevrank('leaderboard', 'user:123');
typescript// Cache-aside pattern async function getData<T>( key: string, fetcher: () => Promise<T>, ttl: number = 300 ): Promise<T> { const cached = await redis.get<T>(key); if (cached) return cached; const data = await fetcher(); await redis.setex(key, ttl, data); return data; } // Usage const user = await getData( `user:${id}`, () => db.query.users.findFirst({ where: eq(users.id, id) }), 300 );
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-05 | fail→pass | 15,526 | 13,369 | -14% | 1 | 1 | 0% | 2,791 | 3,567 | +28% | 0 | 0 | — |
case-01 | fail→fail | 28,001 | 15,360 | -45% | 1 | 1 | 0% | 2,738 | 3,014 | +10% | 0 | 0 | — |
case-02 | fail→fail | 19,459 | 17,346 | -11% | 1 | 1 | 0% | 3,036 | 3,952 | +30% | 0 | 0 | — |
case-03 | pass→pass | 18,428 | 13,464 | -27% | 1 | 1 | 0% | 2,394 | 2,834 | +18% | 0 | 0 | — |
case-04 | fail→pass | 16,045 | 10,026 | -38% | 1 | 1 | 0% | 2,205 | 2,062 | -6% | 0 | 0 | — |
case-06 | fail→pass | 16,722 | 12,084 | -28% | 1 | 1 | 0% | 3,503 | 2,540 | -27% | 0 | 0 | — |
case-07 | pass→pass | 14,142 | 9,851 | -30% | 1 | 1 | 0% | 1,634 | 1,878 | +15% | 0 | 0 | — |
case-08 | fail→pass | 17,532 | 12,857 | -27% | 1 | 1 | 0% | 2,624 | 2,177 | -17% | 0 | 0 | — |
case-09 | pass→pass | 14,554 | 9,518 | -35% | 1 | 1 | 0% | 1,954 | 1,910 | -2% | 0 | 0 | — |
case-10 | pass→pass | 15,149 | 10,415 | -31% | 1 | 1 | 0% | 1,770 | 2,142 | +21% | 0 | 0 | — |
case-11 | pass→pass | 13,496 | 3,917 | -71% | 1 | 1 | 0% | 1,710 | 1,644 | -4% | 0 | 0 | — |
case-12 | pass→pass | 10,926 | 4,673 | -57% | 1 | 1 | 0% | 1,106 | 1,703 | +54% | 0 | 0 | — |
case-13 | pass→pass | 8,051 | 7,118 | -12% | 1 | 1 | 0% | 1,420 | 1,519 | +7% | 0 | 0 | — |
case-14 | pass→pass | 13,087 | 2,694 | -79% | 1 | 1 | 0% | 1,420 | 1,476 | +4% | 0 | 0 | — |
case-15 | fail→pass | 21,556 | 4,605 | -79% | 1 | 1 | 0% | 1,769 | 1,521 | -14% | 0 | 0 | — |
case-16 | pass→pass | 7,033 | 9,730 | +38% | 1 | 1 | 0% | 1,148 | 1,507 | +31% | 0 | 0 | — |
case-17 | pass→pass | 11,303 | 9,368 | -17% | 1 | 1 | 0% | 2,149 | 1,912 | -11% | 0 | 0 | — |
case-18 | pass→pass | 19,240 | 10,768 | -44% | 1 | 1 | 0% | 2,622 | 2,760 | +5% | 0 | 0 | — |
case-19 | pass→pass | 15,022 | 9,122 | -39% | 1 | 1 | 0% | 1,984 | 2,541 | +28% | 0 | 0 | — |
case-20 | pass→pass | 16,272 | 17,657 | +9% | 1 | 1 | 0% | 2,716 | 4,225 | +56% | 0 | 0 | — |
case-21 | pass→pass | 15,601 | 23,568 | +51% | 1 | 1 | 0% | 2,934 | 4,421 | +51% | 0 | 0 | — |
case-22 | fail→pass | 11,899 | 11,105 | -7% | 1 | 1 | 0% | 2,221 | 3,255 | +47% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +27 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.