hai-cache

Automate caching operations across in-memory and Redis backends.

3|7|Updated Jan 28, 2026
One-click install
npx skills add https://github.com/hai-series/hai-framework --skill hai-cache
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: hai-cache
Source: https://github.com/hai-series/hai-framework/tree/main/packages/cli/templates/skills/hai-cache
Command: npx skills add https://github.com/hai-series/hai-framework --skill hai-cache

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

使用 @h-ai/cache 提供统一的内存和 Redis 缓存能力,涵盖 KV、Hash、List、Set、ZSet 以及分布式锁等场景,帮助提升缓存一致性与性能。

Core Features & Use Cases

  • 提供 KV、Hash、List、Set、ZSet 的统一 API,并支持 TTL、持久化和过期策略。
  • 具备分布式锁、集合运算、排行榜等高级缓存场景的能力,适用于分布式应用和多节点环境。
  • 结合 IAM、缓存穿透保护等模式,提升数据访问速度和系统鲁棒性。

Quick Start

通过初始化 cache 模块并配置缓存类型、TTL 与分布式锁,开始使用 hai-cache 的 KV、Hash、List、Set、ZSet 接口以提升应用性能。

Frequently Asked Questions about hai-cache

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement distributed locks with Redis in a multi-node application?

Distributed locks in Redis are automated through a unified API that manages lock acquisition and release safely across multi-node environments. This ensures predictable concurrency control for distributed applications without manual lock handling.

Can I use a single API for Redis and in-memory caching backends?

A unified API supports both in-memory and Redis caching backends seamlessly. It provides init, use, and close lifecycle management with configuration validation, ensuring safe and predictable caching behavior across pluggable backends.

What Redis data structures are supported for advanced caching scenarios?

KV, Hash, List, Set, and ZSet operations are fully supported for advanced caching scenarios. These structures enable complex use cases like set operations, leaderboards, and TTL management within a single unified interface.

How do I manage cache TTL and expiration policies for distributed systems?

Cache TTL and expiration policies are managed automatically through the unified caching layer. The system handles TTL configuration, persistence strategies, and expiration to maintain cache consistency and optimize data access performance.

Does this caching approach protect against cache penetration in distributed environments?

Cache penetration protection is integrated using IAM patterns and related cache strategies. This combination enhances data access speed and system robustness by preventing invalid queries from overwhelming the backend data stores.