CacheLayer Manual#
CacheLayer is a standalone caching toolkit for PHP 8.3+ with:
PSR-6 and PSR-16 support behind one facade (
Cache)local, distributed, and cloud cache adapters
generation-tag invalidation (
setTagged,invalidateTag,invalidateTags)stampede-resistant
remember()with bounded pluggable locksadapter-level metrics export hooks
payload compression controls
Closure-only serialization through Opis Closure
process-local memoization helpers (
memoize,remember,once)
Project Background#
CacheLayer was separated from the existing Intermix project for better package visibility and focused feature enrichment around caching.
How to Use This Manual#
Start with
cachefor the unified API and factory overview.Read
adapters/indexto choose a backend and copy its example.Follow
cookbookfor complete end-to-end process flows.Use
metrics-and-lockingfor production visibility and stampede control.
Quick Start#
use Infocyph\CacheLayer\Cache\Cache;
$cache = Cache::memory('app');
$profile = $cache->remember(
'user.42',
fn () => ['id' => 42, 'name' => 'Ada'],
ttl: 300,
tags: ['users'],
);
$cache->invalidateTag('users');
Guide
- Cache facade
- Atomic Counters
- Cache Adapters
- Array Adapter (
memory) - WeakMap Adapter (
weakMap) - Null Adapter (
nullStore) - Tiered Adapter (
tiered) - File Adapter (
file) - PHP Files Adapter (
phpFiles) - APCu Adapter (
apcu) - Memcached Adapter (
memcached) - Redis Adapter (
redis) - Valkey Adapter (
valkey) - Redis Cluster Adapter (
redisCluster) - SQLite Adapter (
sqlite) - PDO Adapter (
pdo) - Shared Memory Adapter (
sharedMemory) - MongoDB Adapter (
mongodb) - ScyllaDB Adapter (
scylla) - Serialization in Adapters
- Array Adapter (
- Cookbook and Process Flows
- Metrics and Locking
- Node Cache
- Cluster Cache
- Security Guide
- Closure Serialization
- Memoization
- Global Helper Functions