---
title: "Introduction"
description: "Thin PSR-6 and PSR-16 layer over symfony/cache for local backends, with memoizing, safe keys, warming and clearing"
type: "docs"
category: "doc"
tags: []
authors: [Anonymous]
date: "2026-10-10"
last_update: "2026-10-10"
time_minutes: 2
draft: false
unlisted: false
url: "https://www.derafu.dev/docs/core/cache/introduction"
---

# Consistent PSR-6/PSR-16 Cache Wiring Across Derafu Packages

[![GitHub](https://img.shields.io/badge/github-derafu%2Fcache-blue?logo=github)](https://github.com/derafu/cache)
![GitHub last commit](https://img.shields.io/github/last-commit/derafu/cache/main)
![CI Workflow](https://github.com/derafu/cache/actions/workflows/ci.yml/badge.svg?branch=main&event=push)
![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/derafu/cache)
![GitHub Issues](https://img.shields.io/github/issues-raw/derafu/cache)
![Total Downloads](https://poser.pugx.org/derafu/cache/downloads)
![Monthly Downloads](https://poser.pugx.org/derafu/cache/d/monthly)

A small, opinionated layer over [`symfony/cache`](https://symfony.com/doc/current/components/cache.html) 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](https://www.derafu.dev/docs/core/cache/scope-and-stores#scope-local-only) below.

## Installation

```bash
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`](https://github.com/derafu/cache/blob/main/composer.json).

## Requirements

PHP 8.5+. Depends on [`symfony/cache`](https://symfony.com/doc/current/components/cache.html), `psr/cache`, and `psr/simple-cache`.



---
Last updated on 10/10/2026

