create-cache-aside
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "create-cache-aside":https://skillpi.com/zh/skills/deepskill-c47a3758a03db735286f6b5d1da5a3c7db9b80c8f1574c30b7a90d74898370df。安装前核对上游来源和版本:https://github.com/dykyi-roman/awesome-claude-code。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
为 PHP 8.4 生成缓存旁路(Cache-Aside)模式实现。创建具有 PSR-16 集成的缓存执行器,支持通过分布式锁实现惊群保护、基于标签的失效机制以及键生成功能,包含单元测试。
介绍来源: third_party · dykyi-roman · 0.0.1 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 适合谁
- 翻译待完成,请参阅来源文档。
- 实测状态
- 未测试
文件浏览
Frontmatter
name: create-cache-aside
description: Generates Cache-Aside pattern for PHP 8.4. Creates cache executor with PSR-16 integration, stampede protection via distributed locking, tag-based invalidation, and key generation. Includes unit tests.Cache-Aside Generator
Creates Cache-Aside infrastructure with stampede protection and tag-based invalidation.
When to Use
| Scenario | Example |
|---|---|
| Read-heavy workloads | Product catalog, user profiles |
| Expensive queries | Complex reports, aggregated data |
| External API responses | Third-party API caching |
| Computed values | Pricing calculations, search results |
Component Characteristics
CacheAsideInterface
get(string $key, callable $loader, int $ttl): mixed— load from cache or computeinvalidate(string $key): void— remove specific cache entryinvalidateByTag(string $tag): void— remove all entries tagged with given tag
CacheKeyGenerator
- Builds deterministic cache keys from prefix and parameters
- Hashes long keys to prevent exceeding storage limits
- Supports tag-based key grouping
CacheAsideExecutor
- PSR-16 SimpleCache integration
- Configurable TTL per cache operation
- Stampede protection via distributed locking
- Prevents thundering herd on cache miss
CacheInvalidator
- Tag-based invalidation (invalidate all entries for a tag)
- Pattern-based clearing (wildcard key matching)
- Batch invalidation support
Generation Process
Step 1: Generate Domain Components
Path: src/Domain/Shared/Cache/
CacheAsideInterface.php— Cache-aside contractCacheKeyGeneratorInterface.php— Key generation contract
Step 2: Generate Infrastructure Components
Path: src/Infrastructure/Cache/
CacheKeyGenerator.php— Key builder with hashingCacheAsideExecutor.php— PSR-16 cache executor with lockingCacheInvalidator.php— Tag-based and pattern-based invalidationCacheLockInterface.php— Distributed lock contractRedisCacheLock.php— Redis-based lock implementation
Step 3: Generate Tests
CacheKeyGeneratorTest.php— Key generation and hashing testsCacheAsideExecutorTest.php— Cache hit/miss, stampede protection testsCacheInvalidatorTest.php— Tag and pattern invalidation tests
File Placement
| Component | Path |
|---|---|
| Domain Interfaces | src/Domain/Shared/Cache/ |
| Infrastructure | src/Infrastructure/Cache/ |
| Unit Tests | tests/Unit/Infrastructure/Cache/ |
Naming Conventions
| Component | Pattern | Example |
|---|---|---|
| Interface | CacheAsideInterface |
CacheAsideInterface |
| Key Generator | CacheKeyGenerator |
CacheKeyGenerator |
| Executor | CacheAsideExecutor |
CacheAsideExecutor |
| Invalidator | CacheInvalidator |
CacheInvalidator |
| Lock Interface | CacheLockInterface |
CacheLockInterface |
| Lock Impl | {Store}CacheLock |
RedisCacheLock |
| Test | {ClassName}Test |
CacheAsideExecutorTest |
Quick Template Reference
CacheAsideInterface
interface CacheAsideInterface
{
/**
* @template T
* @param callable(): T $loader
* @return T
*/
public function get(string $key, callable $loader, int $ttl = 3600): mixed;
public function invalidate(string $key): void;
public function invalidateByTag(string $tag): void;
}
CacheKeyGenerator
final readonly class CacheKeyGenerator
{
public function __construct(private string $prefix = 'app');
public function generate(string $context, string ...$parts): string;
public function generateHashed(string $context, string ...$parts): string;
}
CacheLockInterface
interface CacheLockInterface
{
public function acquire(string $key, int $ttl = 10): bool;
public function release(string $key): void;
}
Usage Example
$executor = new CacheAsideExecutor($cache, $lock, defaultTtl: 3600);
// Cache-aside: returns cached value or computes via loader
$product = $executor->get(
key: 'product:123',
loader: fn() => $repository->findById(123),
ttl: 1800
);
// Invalidate on update
$executor->invalidate('product:123');
// Tag-based invalidation
$invalidator->invalidateByTag('products');
Pattern Comparison
| Pattern | Description | Use Case |
|---|---|---|
| Cache-Aside | App manages cache (check → miss → load → store) | Read-heavy, tolerates stale data |
| Read-Through | Cache loads data on miss (transparent to app) | Simpler app code, cache manages loading |
| Write-Through | Write to cache and DB simultaneously | Strong consistency needed |
| Write-Behind | Write to cache, async write to DB | High write throughput, eventual consistency |
Anti-patterns to Avoid
| Anti-pattern | Problem | Solution |
|---|---|---|
| No TTL | Stale data served forever | Always set TTL, even long ones |
| Thundering herd | All requests compute on cache miss | Stampede protection with locking |
| Cache poisoning | Invalid data cached | Validate data before caching |
| Inconsistent invalidation | Update DB but forget cache | Use events/listeners for invalidation |
| Key collisions | Different data for same key | Use prefix + context + params |
| Over-caching | Memory waste, stale data | Cache only expensive/frequent operations |
References
For complete PHP templates and examples, see:
references/templates.md— CacheAsideInterface, CacheKeyGenerator, CacheAsideExecutor, CacheInvalidator, lock templatesreferences/examples.md— Repository integration, event-driven invalidation, and unit tests
当前收录版本
0.0.1
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 提供完整的缓存旁路模式实现,适用于高频读取场景
- 集成 PSR-16 标准,支持分布式锁和标签失效机制
- 包含单元测试,确保代码质量
亮点
- description 明确描述功能,覆盖多种使用场景
- 触发词精准完整,边界清晰
待提升项
-
文档过长 原报告严重程度:轻微
文档约 600 行,超出建议的 500 行限制
改进建议:考虑拆分文档或精简内容
亮点
- 结构清晰,分步骤生成
- 包含接口定义、实现类、测试用例
- frontmatter 完整
亮点
- 工具来源明确(PSR-16、Redis)
- 参数正确,覆盖异常处理(惊群保护)
- 不可逆操作有确认机制
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。