High-performance caching with Redis for Google Antigravity IDE
# Redis Caching Guide for Google Antigravity
Master caching strategies with Redis in Google Antigravity IDE. This guide covers cache patterns, data structures, pub/sub, and performance optimization.
## Configuration
```typescript
// .antigravity/redis.ts
export const redisConfig = {
features: {
caching: true,
pubsub: true,
sessions: true
}
};
```
## Cache-Aside Pattern
```typescript
import { createClient } from "redis";
const redis = createClient({ url: process.env.REDIS_URL });
await redis.connect();
async function cacheAside<T>(key: string, fetcher: () => Promise<T>, ttl = 3600): Promise<T> {
const cached = await redis.get(key);
if (cached) return JSON.parse(cached);
const data = await fetcher();
await redis.set(key, JSON.stringify(data), { EX: ttl });
return data;
}
```
## Rate Limiting
```typescript
async function rateLimit(id: string, limit: number, windowMs: number) {
const key = `ratelimit:${id}`;
const count = await redis.incr(key);
if (count === 1) await redis.pExpire(key, windowMs);
return count <= limit;
}
```
## Best Practices
1. **Set TTL on keys** - Prevent memory bloat
2. **Use pipelines** - Batch commands
3. **Monitor memory** - Set maxmemory policy
Google Antigravity IDE provides Redis pattern suggestions.This Redis prompt is ideal for developers working on:
By using this prompt, you can save hours of manual coding and ensure best practices are followed from the start. It's particularly valuable for teams looking to maintain consistency across their redis implementations.
Yes! All prompts on Antigravity AI Directory are free to use for both personal and commercial projects. No attribution required, though it's always appreciated.
This prompt works excellently with Claude, ChatGPT, Cursor, GitHub Copilot, and other modern AI coding assistants. For best results, use models with large context windows.
You can modify the prompt by adding specific requirements, constraints, or preferences. For Redis projects, consider mentioning your framework version, coding style, and any specific libraries you're using.