cache/simple-cache-bridge
Bridge any PSR-6 cache pool to PSR-16 SimpleCache. Wrap an existing PSR-6 implementation and use the simpler PSR-16 API in your app while keeping your current cache backend. Part of the PHP-Cache ecosystem.
This package provides a thin bridge to use any PSR-6 cache pool as a PSR-16 (SimpleCache) implementation — useful when integrating legacy PSR-6 libraries or adapters with modern Laravel apps that expect Psr\SimpleCache\CacheInterface. Start by installing via Composer:
composer require cache/simple-cache-bridge
Then, wrap your existing PSR-6 pool (e.g., ArrayCachePool, Symfony Cache pool, or any third-party PSR-6 implementation) with the bridge:
use Cache\SimpleCacheBridge\SimpleCacheBridge;
use ArrayCache\ArrayCachePool;
$psr6Pool = new ArrayCachePool();
$cache = new SimpleCacheBridge($psr6Pool);
In Laravel, you’ll typically use this to register a custom SimpleCache driver in config/cache.php.
Driver Registration: Extend Laravel’s cache manager to support PSR-6-backed SimpleCache. In a service provider’s boot() method, hook into Cache::extend():
Cache::extend('psr6', function ($app) {
$psr6Pool = $app->make(\Symfony\Component\Cache\Adapter\RedisAdapter::class); // or any PSR-6 pool
return new \Cache\SimpleCacheBridge\SimpleCacheBridge($psr6Pool);
});
Then set CACHE_DRIVER=psr6 in .env.
Dependency Injection: Inject Psr\SimpleCache\CacheInterface directly in jobs, commands, or services and bind it via App::singleton() or bind() in a service provider to your PSR-6-backed bridge instance.
Testing: Use this bridge to swap production PSR-6 pools (e.g., Redis) with an ArrayCachePool for testing via Laravel’s Cache::spy() or manual mocking of SimpleCache.
get, set, delete, clear), tagging and advanced expiry logic are lost. Avoid relying on PSR-6-specific features if downstream consumers use SimpleCache.default_ttl in set()/getMultiple() where PSR-6 uses ItemInterface->expiresAfter(). Ensure your PSR-6 pool’s pool-level defaults align with expectations — misalignment may cause items to expire unexpectedly.symfony/cache’s SimpleCacheAdapter), unless you specifically need interoperability.How can I help you explore Laravel packages today?