caching-strategy by aj-geddes/useful-ai-prompts
npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill caching-strategy实施有效的缓存策略,以提升应用程序性能、降低延迟并减轻后端系统负载。
最小工作示例:
import Redis from "ioredis";
interface CacheOptions {
ttl?: number; // Time to live in seconds
prefix?: string;
}
class CacheService {
private redis: Redis;
private defaultTTL = 3600; // 1 hour
constructor(redisUrl: string) {
this.redis = new Redis(redisUrl, {
retryStrategy: (times) => {
const delay = Math.min(times * 50, 2000);
return delay;
},
maxRetriesPerRequest: 3,
});
this.redis.on("connect", () => {
console.log("Redis connected");
});
this.redis.on("error", (error) => {
// ... (完整实现请参阅参考指南)
references/ 目录下的详细实现:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 指南 | 内容 |
|---|---|
| Redis 缓存实现 (Node.js) | Redis 缓存实现 (Node.js) |
| 缓存装饰器 (Python) | 缓存装饰器 (Python) |
| 多级缓存 | 多级缓存 |
| 缓存失效策略 | 缓存失效策略 |
| HTTP 缓存头 | HTTP 缓存头 |
每周安装量
148
代码仓库
GitHub 星标数
127
首次出现
2026年1月21日
安全审计
安装于
opencode123
gemini-cli119
codex117
cursor115
claude-code114
github-copilot102
Implement effective caching strategies to improve application performance, reduce latency, and decrease load on backend systems.
Minimal working example:
import Redis from "ioredis";
interface CacheOptions {
ttl?: number; // Time to live in seconds
prefix?: string;
}
class CacheService {
private redis: Redis;
private defaultTTL = 3600; // 1 hour
constructor(redisUrl: string) {
this.redis = new Redis(redisUrl, {
retryStrategy: (times) => {
const delay = Math.min(times * 50, 2000);
return delay;
},
maxRetriesPerRequest: 3,
});
this.redis.on("connect", () => {
console.log("Redis connected");
});
this.redis.on("error", (error) => {
// ... (see reference guides for full implementation)
Detailed implementations in the references/ directory:
| Guide | Contents |
|---|---|
| Redis Cache Implementation (Node.js) | Redis Cache Implementation (Node.js) |
| Cache Decorator (Python) | Cache Decorator (Python) |
| Multi-Level Cache | Multi-Level Cache |
| Cache Invalidation Strategies | Cache Invalidation Strategies |
| HTTP Caching Headers | HTTP Caching Headers |
Weekly Installs
148
Repository
GitHub Stars
127
First Seen
Jan 21, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode123
gemini-cli119
codex117
cursor115
claude-code114
github-copilot102
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
111,800 周安装
Claude Opus 4.5 迁移指南:一键从Sonnet/Opus旧版升级,解决工具过度触发等问题
167 周安装
Sentry .NET SDK 设置指南:错误监控、性能追踪与日志记录
167 周安装
Excel 数据分析器 - 自动检测数据结构、质量问题与统计模式,生成数据清洗报告
167 周安装
PDF文档处理技能:2026年最佳实践,支持创建、提取、合并、拆分、OCR与表单自动化
167 周安装
视频营销专家 | 全平台视频策略、制作与分发,提升品牌影响力与转化率
167 周安装
Smithery AI 智能体市场:连接10万技能与MCP工具,提升开发效率
167 周安装