Cache interface, enabling seamless integration for Laravel applications using Doctrine ORM (e.g., for query caching, metadata caching, or third-party Doctrine-dependent libraries).FileCache, RedisCache, DatabaseCache) can now power Doctrine’s caching layer without requiring custom implementations.Doctrine\Common\Cache\FilesystemCache), allowing future migration to PSR-6-native solutions.Cache provider with the bridge, injecting a PSR-6 pool (e.g., Laravel’s Cache facade or a custom adapter).cache/psr-6-doctrine-bridge (MIT-licensed, no transitive conflicts with Laravel).apcu, memcache).Cache interface methods (fetch(), save(), delete()) map 1:1 to PSR-6, ensuring no breaking changes for existing Doctrine integrations.CacheItemPoolInterface supports tags, but Doctrine’s Cache lacks this—bridge may not expose advanced features.save() uses timestamps; PSR-6 uses CacheItem::expiresAfter(). The bridge must handle conversions transparently.doctrine/cache:^2.2 (latest stable).FilesystemCache vs. RedisCache via the bridge.Cache::tags() if Doctrine code uses contains()/fetch()?array, database) or only PSR-6-compliant ones?CacheException) or Doctrine’s CacheException?Cache interface, will this bridge become obsolete?redis, memcached) as the underlying PSR-6 pool.Doctrine\Common\Cache\FilesystemCache with the bridge in config/packages/doctrine.yaml or service definitions.doctrine/orm or symfony/messenger that expect Doctrine’s Cache.EntityManager::getCache(), MetadataFactory).Doctrine\Common\Cache\Cache instances to replace.composer.json:
composer require cache/psr-6-doctrine-bridge
use Psr\Cache\CacheItemPoolInterface;
use Cache\Bridge\Doctrine\DoctrineCacheBridge;
$psr6Pool = Cache::store('redis')->getPsr6Adapter();
$doctrineCache = new DoctrineCacheBridge($psr6Pool);
# config/packages/doctrine.yaml
doctrine:
orm:
metadata_cache_driver: doctrine_cache_bridge
query_cache_driver: doctrine_cache_bridge
result_cache_driver: doctrine_cache_bridge
services:
doctrine_cache_bridge:
class: Cache\Bridge\Doctrine\DoctrineCacheBridge
arguments:
- '@psr6.cache' # Your PSR-6 pool service
EntityManager::clear()) with cached queries/metadata.Cache interface).stash, cache, symfony/cache) will work.Cache::tags() is not exposed by Doctrine’s Cache interface—tags must be managed manually in the PSR-6 layer.redis, memcached) are supported; file or array may lack performance benefits.Doctrine\Common\Cache instances, monitoring:
Cache::extend('redis', fn($app) => $app['redis']->logger(...))).FilesystemCache as a backup during migration.pipeline support in PSR-6 adapter).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| PSR-6 pool unavailable (e.g., Redis down) | Doctrine falls back to no cache or throws exceptions. | Configure a fallback cache (e.g., array driver). |
| Serialization errors | Doctrine cache corrupts or fails to load. | Use a robust PSR-6 adapter (e.g., stash with igbinary). |
| TTL misconfiguration | Stale data in Doctrine caches. | Validate TTLs in PSR-6 pool match Doctrine’s expectations. |
Bridge bug (e.g., fetch() returns wrong data) |
Doctrine queries return incorrect results. | Test with known cache states; roll back if issues arise. |
CacheItem lifecycle).How can I help you explore Laravel packages today?