oxhq/cachelet
Composer 安装命令:
composer create-project oxhq/cachelet
包简介
The full Cachelet suite for Laravel.
README 文档
README
The cache operations layer for Laravel.
Stop flushing blind.
Cachelet gives every important cache entry a stable coordinate: what it belongs to, where it lives, how it was keyed, how long it should live, and how it can be invalidated without reaching for a whole-store flush.
Laravel already gives you excellent cache primitives. Cachelet turns those primitives into an inspectable operating model across app-level values, Eloquent models, query results, route responses, and optional telemetry exports.
use Oxhq\Cachelet\Facades\Cachelet; $users = Cachelet::for('users.index') ->from(['page' => 1, 'role' => 'admin']) ->onStore('redis') ->ttl('+15 minutes') ->remember(fn () => User::query()->where('role', 'admin')->paginate());
Why Cachelet
Production cache bugs are rarely about calling remember() wrong. They are about invisible state:
- Which cache family owns this key?
- Which store was used?
- Which request, model, query, or service produced it?
- What is safe to invalidate?
- Did the fresh path recover after the intervention?
Cachelet makes those answers first-class.
What You Get
- Deterministic coordinates for core, model, query, and request caches.
- Stable key generation from normalized payloads.
- TTL and stale-while-revalidate with lock-aware refresh behavior.
- Scoped invalidation by key, prefix, tag, or explicit scope.
- Local inspection commands for listing, inspecting, flushing, and pruning cache families.
- Canonical telemetry through
cachelet.telemetry.v1. - Optional exporter support when cache visibility needs to feed dashboards, audit trails, or developer tooling.
Cachelet is useful without an external service. The exporter is a tooling bridge for teams that want canonical cache evidence outside the Laravel process.
Install
Most teams should start with the full suite:
composer require oxhq/cachelet
Use focused packages when a project only needs one layer:
| Package | Use it for |
|---|---|
oxhq/cachelet |
Full suite: core + model + query + request + exporter |
oxhq/cachelet-core |
Generic builders, keys, TTL/SWR, invalidation, inspection, telemetry |
oxhq/cachelet-model |
Eloquent model caching, payload shaping, observer invalidation |
oxhq/cachelet-query |
Query builder and Eloquent result caching |
oxhq/cachelet-request |
Request/response caching middleware and route integration |
oxhq/cachelet-exporter |
Optional telemetry export for external tooling |
See the full install guide: docs/install-matrix.md.
Quick Tour
Core Values
$report = Cachelet::for('reports.sales') ->from(['from' => '2026-01-01', 'to' => '2026-01-31']) ->ttl(1800) ->remember(fn () => $service->salesReport());
Eloquent Models
use Oxhq\Cachelet\Traits\UsesCachelet; class User extends Model { use UsesCachelet; } $profile = $user->cachelet() ->exclude(['updated_at']) ->ttl(300) ->remember(fn () => $user->fresh());
Queries
$admins = User::query() ->where('role', 'admin') ->cachelet() ->ttl(300) ->rememberQuery();
Route Responses
Route::get('/users', UserIndexController::class) ->name('users.index') ->cachelet(600, [ 'vary' => [ 'query' => true, 'headers' => ['X-Tenant'], 'auth' => true, ], 'namespace' => 'users', ]);
More examples live in examples/.
Operator Commands
Cachelet keeps enough sidecar state to make cache families visible from the CLI:
php artisan cachelet:list users.index php artisan cachelet:inspect users.index php artisan cachelet:flush users.index php artisan cachelet:prune
The operator guide explains what each answer means: docs/operator-questions.md.
The Contract
Every coordinate resolves to cachelet.coordinate.v1 with:
module:core,model,query, orrequestprefixkeyttlversionstoretagsswrmetadata
When observability events are enabled, Cachelet emits CacheletTelemetryRecorded records using cachelet.telemetry.v1.
See docs/operations.md for the full runtime contract.
When To Use Cachelet
Use raw Laravel cache calls when the cache is simple, local, and obvious.
Use a narrow point solution when the app only needs one specialized job, such as response caching.
Use Cachelet when a Laravel app has more than one cache surface and the team needs one vocabulary for keys, scopes, stores, invalidation, inspection, and telemetry.
Comparison guide: docs/comparison.md.
Docs
- Start here:
docs/README.md - Install matrix:
docs/install-matrix.md - Migration guide:
docs/migration.md - Operations contract:
docs/operations.md - Operator questions:
docs/operator-questions.md - Benchmarks:
docs/benchmarks.md - Releases and publishing:
docs/releases.md
Support Matrix
- Laravel
12.xand13.x - PHP
8.2,8.3,8.4, and8.5 - CI covers Redis plus PostgreSQL-backed cache integration paths
Stability
0.2.x is intended to be production-usable. The package family is still early, so focused API tightening may happen before 1.0 if real usage proves a better contract.
Cachelet does not claim automatic relational invalidation for arbitrary query graphs, CDN orchestration, Blade fragment caching, or perfect zero-config inference for every cache use case.
Community
- Contributing:
CONTRIBUTING.md - Security reports:
SECURITY.md - Support policy:
SUPPORT.md - Code of conduct:
CODE_OF_CONDUCT.md
Repository
This monorepo is the public source of truth for oxhq/cachelet and the focused split packages. Maintainer workflow details live in CONTRIBUTING.md, docs/monorepo.md, and docs/releases.md.
oxhq/cachelet 适用场景与选型建议
oxhq/cachelet 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「cache」 「laravel」 「invalidation」 「query-cache」 「response-cache」 「swr」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 oxhq/cachelet 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 oxhq/cachelet 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 oxhq/cachelet 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
russian-doll php library
repository php library
Cache items with associated tagging information and subsequently fetch or delete items based on tags.
Laravel 5 - Repositories to the database layer
A Statamic invalidation class for static caching with advanced capabilities.
Rinvex Repository is a simple, intuitive, and smart implementation of Active Repository with extremely flexible & granular caching system for Laravel, used to abstract the data layer, making applications more flexible to maintain.
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 46
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-20