Skip to content

Solo CachePSR-16 caching for files and Redis.

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.

Solo Cache

Store and read ​

php
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.

Installation ​

PHP 8.3+ is required. The only runtime dependency is psr/simple-cache; the Redis adapter also needs the redis extension.

sh
composer require solophp/cache

Continue with the getting-started guide.

MIT licensed.