Plain PSR-16
Both adapters implement Psr\SimpleCache\CacheInterface. Type-hint the interface and move from the file cache to Redis without touching the calling code.
Store any serializable value with a TTL. File writes publish atomically, a cached false or null comes back as a hit, and you decide whether a broken backend throws or falls back.
use Solo\Cache\Adapter\FileAdapter;
$cache = new FileAdapter(__DIR__ . '/var/cache/catalog');
$cache->set('product.42', ['name' => 'Desk', 'price' => 249], 3600);
$product = $cache->get('product.42'); // ['name' => 'Desk', 'price' => 249]
$cache->set('feature.beta', false);
$cache->get('feature.beta', 'unknown'); // false: a stored false is a hit
$cache->get('feature.gamma', 'unknown'); // 'unknown'Swap in RedisAdapter with a connected Redis client and the same calls work against Redis. Read the getting-started guide for both adapters, expiration, batches and failure handling.
PHP 8.3+ is required. The only runtime dependency is psr/simple-cache; the Redis adapter also needs the redis extension.
composer require solophp/cacheContinue with the getting-started guide.