Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Simple Cache Bridge Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

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.

Implementation Patterns

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

Gotchas and Tips

  • No native Laravel integration: This package does not integrate with Laravel’s config or store factory out of the box — you must wire it manually.
  • PSR-6 ↔ PSR-16 semantic gaps: PSR-6 supports tagging, expiration per item, and batch operations; PSR-16 does not. While the bridge maps basic operations (get, set, delete, clear), tagging and advanced expiry logic are lost. Avoid relying on PSR-6-specific features if downstream consumers use SimpleCache.
  • Lifetime handling: PSR-16 defaults 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.
  • Pool lifetime: The bridge holds a reference to the underlying pool. Be mindful of pool scope — e.g., if using Symfony’s cache pool, confirm it’s not scoped to request lifetime when injected as a singleton.
  • Stability & maintenance: Last release was in 2022. Though stable, verify compatibility with newer PHP versions (tested up to PHP 8.0). For new projects, prefer native PSR-16 implementations (e.g., symfony/cache’s SimpleCacheAdapter), unless you specifically need interoperability.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport