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
tag-version invalidation (
setTagged,invalidateTag,invalidateTags)stampede-safe
remember()with pluggable lock providersadapter-level metrics export hooks
payload compression controls
value serialization for closures and resources
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', function ($item) {
$item->expiresAfter(300);
return ['id' => 42, 'name' => 'Ada'];
}, tags: ['users']);
$cache->invalidateTag('users');
Guide
- Cache Facade (
Cache) - Cache Adapters
- Array Adapter (
memory) - WeakMap Adapter (
weakMap) - Null Adapter (
nullStore) - Chain Adapter (
chain) - File Adapter (
file) - PHP Files Adapter (
phpFiles) - APCu Adapter (
apcu) - Memcached Adapter (
memcache) - 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 (
scyllaDb) - Serialization in Adapters
- Array Adapter (
- Cookbook and Process Flows
- Metrics and Locking
- Security Guide
- Value Serialization
- Memoization
- Global Helper Functions