Consistent PSR-6/PSR-16 Cache Wiring Across Derafu Packages
A small, opinionated layer over symfony/cache for the local backends (no connection, no credentials, no network round trip) — plus a handful of things PSR-6/PSR-16 and symfony/cache genuinely don’t provide on their own.
Why
symfony/cache‘s own file-based adapters (PhpFilesAdapter, FilesystemAdapter) accept a null directory and silently fall back to one you’d have to read the source to find. A cache backed by the filesystem that nobody can point to exactly is a cache nobody can clear with confidence — derafu/cache’s adapters make $namespace and $directory required instead, so that decision is never made for you.
Past that one guardrail, this package adds a handful of things PSR-6/PSR-16 and symfony/cache genuinely don’t provide on their own: a safe way to build cache keys without hand-rolling sanitization, a stampede-safe “compute and remember” helper, and a way to inspect or clear a cache directory without needing to reconstruct whatever wrote to it.
It is not a general abstraction over every backend symfony/cache supports. PSR-6/PSR-16 already are that abstraction — building another one on top would just be indirection. See Scope below.
Installation
composer require derafu/cache
ext-apcu (for LocalCacheBackend::Apcu) and symfony/console (for the bundled commands) are both entirely optional — see composer.json’s suggest.
Requirements
PHP 8.5+. Depends on symfony/cache, psr/cache, and psr/simple-cache.