Weave 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

Doctrine Redis Cache Bundle Laravel Package

stfalcon-studio/doctrine-redis-cache-bundle

Symfony bundle that configures Redis as a Doctrine cache provider, letting you cache ORM metadata, query results, and second-level cache data for faster database-backed applications with minimal setup.

View on GitHub
Deep Wiki
Context7

Getting Started

  1. Install the bundle. composer require stfalcon-studio/doctrine-redis-cache-bundle. Symfony Flex should register it; otherwise add the bundle class to config/bundles.php.
  2. Stand up the cache infrastructure first. This bundle only changes the namespace of Doctrine cache pools — it does not create a Redis connection or configure framework.cache. You still need a Redis provider/pool (e.g. cache.adapter.redis) and Doctrine pointed at the Doctrine pools (doctrine.orm.result_cache_pool, query_cache_pool, metadata_cache_pool).
  3. Add the namespace config. The exact key tree lives in vendor/stfalcon-studio/doctrine-redis-cache-bundle/src/DependencyInjection/Configuration.php; the shape is typically something like:
    # config/packages/stfalcon_doctrine_redis_cache.yaml
    stfalcon_doctrine_redis_cache:
        namespace: 'myapp_%kernel.environment%'
    
  4. Verify the wiring. php bin/console cache:pool:list, then php bin/console debug:container doctrine.result_cache_pool and inspect the cache.pool tag’s namespace attribute. Confirm in Redis with redis-cli --scan --pattern 'myapp_*' | head.
  5. First use case: two apps (or staging + prod) sharing one Redis instance. Give each a distinct, stable namespace so Doctrine’s result/metadata/query caches don’t collide, and so cache:pool:clear only touches the intended pool.

Where to look first: the README, DependencyInjection/Configuration.php, and the compiler pass that rewrites cache.pool tags.

Implementation Patterns

  • Environment-scoped namespace. namespace: 'myapp_%kernel.environment%' gives you myapp_prod, myapp_staging, etc. A sensible default when sharing Redis.
  • Per-app namespaces in shared Redis. For multiple services use myapp_orders_prod, myapp_billing_prod. This is the main reason to reach for the bundle.
  • Deploy-stable vs deploy-versioned. Keep the namespace constant if you want warm Doctrine caches to survive deploys. Include %env(APP_VERSION)% or a release slug if you want an implicit flush per release — but old keys orphan until TTL.
  • CI/preview isolation. Use something like myapp_ci_%env(CI_PIPELINE_ID)%; clean up with a SCAN-based script because Symfony won’t know about stale namespaces.
  • Targeted invalidation. php bin/console cache:pool:clear doctrine.result_cache_pool clears only that pool’s namespace; cache:pool:invalidate-tags respects the namespace too.
  • Confirm Doctrine is actually using the pools. If doctrine.orm.result_cache_pool still points at cache.app, the namespace change has no effect.
  • Local dev separation. Use a distinct namespace and/or Redis DB for dev so a local cache:clear can’t touch production keys.
  • Fallback compiler pass. Under the hood this is just setting namespace on the cache.pool tag. If the bundle lags a Symfony release, a small compiler pass in your app can replicate it.

Gotchas and Tips

  • Namespace ≠ Redis prefix or DB. Symfony prefixes cache item keys inside the pool; it doesn’t change Redis PREFIX, DB index, or ACLs. For hard isolation use separate DBs/instances/ACL users.
  • Changing a namespace is a silent cache flush. Old keys become unreachable and linger until TTL. Plan redis-cli --scan + UNLINK cleanup, or keep lifetimes sane.
  • Tag invalidation data is namespaced too. Renaming the namespace loses the ability to invalidate old tags.
  • Compiler-pass ordering matters. Another bundle or your own pass can overwrite the cache.pool tag. Verify with debug:container --tag=cache.pool and check the namespace attribute.
  • It doesn’t configure Redis. You still need framework.cache with a Redis adapter/provider, and either the redis PHP extension or Predis.
  • It likely targets only Doctrine pools. Don’t assume cache.app / cache.system get the custom namespace unless the docs say so.
  • Keep namespaces short and ASCII. Avoid whitespace/control characters and very long strings — every key pays the length cost. Confirm the actual Redis keys with SCAN rather than assuming the format.
  • Redis Cluster. A namespace does not colocate keys into the same hash slot. {hash tags} can, but verify Symfony’s key builder handles braces before relying on it.
  • Debugging checklist: cache:pool:list → debug:container <pool> → debug:container --tag=cache.pool → redis-cli --scan --pattern '<ns>*'. If keys lack the namespace, the pool isn’t using the tag you think it is.
  • Prefer targeted clears in deploys. cache:clear runs all pool clearers; cache:pool:clear <pool> avoids collateral damage.
  • Tests: use a unique namespace per run (test_%env(TEST_TOKEN)%) and clear it, or you’ll get cross-run Doctrine cache contamination.
  • Small-package hygiene. With a handful of stars/dependents, pin the version, read release diffs, and keep the tiny compiler-pass fallback in mind. Test against your Symfony/DoctrineBundle versions before upgrading.
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.
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource