rajmundtoth0/hybrid-cache
A Laravel package that adds a hybrid cache layer, combining fast in-memory storage with persistent backends to reduce latency and database load. It offers simple cache APIs and configurable drivers for scalable PHP applications.
hybrid-cache is a two-tier cache store for Laravel: an in-process (per-worker) layer fronting a shared backend, exposed through the standard Cache facade and contract. Release 0.2.0 makes two changes of consequence to a TPM's evaluation and nothing else:
touch support. TTL extension without rewriting the payload. Functionally small; architecturally useful, because it enables sliding-expiration and "refresh-on-read" patterns (sessions, rate-limit windows, feature-flag snapshots) without a read-modify-write on the backing store.Architecture fit. The two-tier pattern is a legitimate fit for read-heavy, latency-sensitive paths — hot config, permission sets, tenant metadata — where the shared-store round trip dominates request time. It is a poor fit for anything with tight write-then-read consistency requirements, since the local layer is invalidated by TTL, not by write propagation.
Integration feasibility. Low effort to wire in: Composer install, package auto-discovery, a new entry under config/cache.php stores, and an env switch. Rollback is a config change, not a code change — provided the package is not used as a queue/session driver. The touch addition requires no consumer changes; it surfaces as existing Cache::touch() calls silently starting to work on this store instead of throwing.
Technical risk. Material, and concentrated in provenance rather than code quality. The package is at 0.2.0 with two merged changes, a single maintainer, and no stated support policy. The Laravel 13 jump is a strong compatibility statement but also evidence that the version surface is being narrowed aggressively rather than supported broadly. The core risk is coherency: writes to the shared store do not evict peers' in-process copies, so the effective staleness window is the local TTL, and that window is invisible to the application.
Key questions to put to the maintainer before adoption:
touch propagated to it or applied only to the local layer? Divergent TTLs between tiers is the most likely silent-corruption path.Stack fit. Only viable if the target application is on Laravel 13 (or the team is willing to pin 0.1.0 for an earlier major). Establish the framework version across all services first — this is now a hard gate, not a preference. Services on a mixed-version estate should be treated as separate adoption decisions.
Migration path. Do not replace an existing cache store wholesale. Introduce hybrid-cache as an additional named store and route specific, low-risk key families to it — those that are read-mostly, tolerant of seconds-level staleness, and not on a login/permission hot path. Keep the incumbent Redis/database store for everything else. The touch capability is the natural first workload: sliding-expiration keys currently paying a full read-modify-write can move over and be measured in isolation.
Compatibility. Verify against the actual cache usage inventory: tags (supported? if not, any Cache::tags() call site cannot move), atomic locks, increment/decrement, and Cache::remember under concurrency. Under Octane the in-process layer has a fundamentally different lifetime — a worker-lifetime cache rather than a request-lifetime one — so validate memory growth under sustained load before any production traffic.
Sequencing.
touch paths explicitly, comparing TTL observed at each tier.Maintenance. Pin the exact version. Pre-1.0 with a single maintainer means minor bumps can carry breaking behaviour, and the 0.1.0 → 0.2.0 framework jump is the template: expect future releases to track the newest Laravel major rather than backport. Budget for an internal fork or a vendored patch if the maintainer goes quiet — assign explicit ownership of that contingency before adoption, not after.
Support. No commercial backing, no SLA, no published deprecation policy. Escalation path is a GitHub issue. That is acceptable for a peripheral latency optimisation and unacceptable for anything on a revenue path.
Scaling. The local tier scales with the fleet in the wrong direction: each additional worker or node carries its own copy, so aggregate memory grows linearly with instance count, and the staleness window becomes a function of per-node TTL configuration rather than a centralised setting. The shared tier absorbs the write load but sees reduced read load — measure the actual hit-rate shift, since a two-tier cache that mostly misses the local layer adds overhead rather than removing it.
Failure modes to plan for.
touch support; a key can be live in one tier and expired in the other.Ramp-up. Small surface area, but the failure modes are subtle and not self-announcing. Require the team to understand the two-tier invalidation model and to have a staleness diagnostic (key age at each tier) before moving any workload that touches user-visible state. Realistic estimate: half a day to integrate, two to three days to instrument and validate a single key family safely — the instrumentation, not the integration, is the cost.
How can I help you explore Laravel packages today?