Download the PHP package vatvit/freshen-symfony without Composer
On this page you can find all versions of the php package vatvit/freshen-symfony. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download vatvit/freshen-symfony
More information about vatvit/freshen-symfony
Files in vatvit/freshen-symfony
Package freshen-symfony
Short Description Drop-in Symfony bundle for Freshen — stale-while-revalidate cache with cache-stampede prevention: declarative named caches, autowired by name, async invalidation pre-wired, and a Redis/PSR-6 backend.
License MIT
Homepage https://github.com/vatvit/freshen
Informations about the package freshen-symfony
⚠️ Read-only mirror. This repository is the Packagist publish mirror of
packages/symfonyin the Freshen monorepo. Source, issues, and pull requests live there — please don't open them here. Install withcomposer require vatvit/freshen-symfony.
Freshen — Symfony bundle
Drop-in stale-while-revalidate caching for Symfony.
composer require+ a little YAML gives you autowired, per-dataset caches with cache-stampede prevention and async invalidation — no boilerplate.
The Symfony bundle for Freshen brings the caching pieces you normally wire up by hand into declarative config: single-flight recompute so exactly one worker rebuilds a hot key while everyone else is served the last good value (no cache-stampede); preemptive refresh that recomputes an entry before it goes stale, on TTLs and jitter you control; structured keys and effective delete — genuinely evict one exact key or a whole prefix, atomically and in one round-trip; and built-in metrics on every hit, miss, and rebuild. Declare a cache per dataset in YAML, inject it by name, and every cache-related decision is explicit and yours — no container plumbing.
Features
Symfony integration
- Drop-in bundle —
composer require+ a little YAML; the bundle wires the pool, loader, and invalidation listener for you (no manual container plumbing). - Declarative named caches — define one
Freshen\Cacheper dataset inconfig/packages/freshen.yaml(loader + TTLs), each autowired by name (Freshen\Cache $topSellersCache). - Async invalidation, pre-wired — each cache's
Freshen\AsyncHandleris registered on Symfony's PSR-14event_dispatcher, soinvalidate()/refresh()dispatch and are handled with no listener wiring. - Symfony
^6.4 || ^7.0, PHP 8.1 → 8.4 — PHPStan-max, MIT.
Powered by Freshen core
- Stale-while-revalidate — serve the cached value instantly and recompute a fresh one in the background; reads never block on an expired entry.
- Cache-stampede prevention — single-flight leader/follower recompute plus jittered TTLs: one worker rebuilds while everyone else is served the stale value (no thundering herd).
- Structured, hierarchical keys —
Freshen\Keyisdomain / facet [ / schemaVersion ] [ / locale ] / id, with built-in schema versioning and per-locale variants. - Effective delete — genuinely evict one exact key, a whole prefix
(
domain/facet/*), or a batch of selectors — atomically, in a single round-trip. - Redis-backed, PSR-6 core — an atomic Redis driver (single-flight + exact/prefix delete) over a Stash PSR-6 pool; swap in any PSR-6 backend.
- Built-in metrics & fail-open — hit/miss/recompute metrics out of the box, and it serves through backend hiccups instead of failing the request.
Full detail in the core README.
At a glance
composer require, declare a cache in one YAML block, then inject it by name — reading
is two lines, and you never touch the store, a stampede, or serialisation:
On a miss the cache calls your loader, stores the result, and returns it; later reads are served stale-while-revalidate with stampede protection — all automatic.
Install
Register the bundle (Symfony Flex does this automatically):
Configure
Freshen\Cache is per-dataset — each cache binds one loader + TTL — so you declare
named caches. Each references a loader service (yours, implementing
Freshen\Interface\LoaderInterface) and a \Redis client service.
A Freshen cache is one dataset, so you define one entry per data structure (top sellers, prices, …) — a real app has several:
The connection value is a service id for a connected \Redis client. Bring your
own, e.g.:
Use
Inject each cache by name with named-argument autowiring — the argument name is the
camel-cased cache name plus Cache. This is how you reference a dataset whether you have
one cache or many (there is no bare Freshen\Cache "default" — with several datasets it
would be ambiguous, and it would silently break the day you add the second one):
Async invalidation
The bundle registers each cache's Freshen\AsyncHandler on Symfony's PSR-14
event_dispatcher, so invalidate() / invalidateExact() / refresh() (async by
default) dispatch Freshen\{Invalidate,InvalidateExact,Refresh}Event and are handled
without you wiring listeners.
Call it wherever your data changes — e.g. an application service — and the bundle's registered handler does the rest:
Symfony's event_dispatcher is synchronous, so the handler runs within the same
request: the async default decouples invalidation from the call site, it does not by
itself move the work off-process (unlike the Laravel bridge's queue). To skip the event
and invalidate inline, pass SyncMode::SYNC:
Caveat — shared dispatcher fan-out. These events carry a key only, not a cache id, so an async
invalidate($key)is delivered to every configured cache's handler. Where a cache doesn't hold that key it's a harmless no-op, but caches that use colliding key namespaces would cross-invalidate. Give each cache a distinctKeydomain/facet (they naturally differ per dataset) and this is a non-issue.
Security
Tracked by the Packagist security advisory database
— run composer audit to check your install. Report vulnerabilities privately via
GitHub Security Advisories; the full
policy is in SECURITY.md.
Versioning
Independent SemVer, released as symfony-vX.Y.Z. Depends on vatvit/freshen-php via
^1.0. A core patch/minor needs no bridge release; a core major does. See the monorepo
RELEASING.md.
Links
- Core library & full docs: https://github.com/vatvit/freshen (
packages/php) - Manual (non-bundle) wiring: the core README's "Framework integration" section.
All versions of freshen-symfony with dependencies
vatvit/freshen-php Version ^1.0
psr/event-dispatcher Version ^1.0
symfony/config Version ^6.4 || ^7.0
symfony/dependency-injection Version ^6.4 || ^7.0
symfony/http-kernel Version ^6.4 || ^7.0