PHPackages                             stfalcon-studio/doctrine-redis-cache-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. stfalcon-studio/doctrine-redis-cache-bundle

ActiveSymfony-bundle[Database &amp; ORM](/categories/database)

stfalcon-studio/doctrine-redis-cache-bundle
===========================================

Add custom namespace for doctrine cache pools.

4.0.0(3mo ago)4160.8k↓28%3[1 PRs](https://github.com/stfalcon-studio/DoctrineRedisCacheBundle/pulls)MITPHPPHP &gt;=8.4CI passing

Since Aug 2Pushed 3mo ago2 watchersCompare

[ Source](https://github.com/stfalcon-studio/DoctrineRedisCacheBundle)[ Packagist](https://packagist.org/packages/stfalcon-studio/doctrine-redis-cache-bundle)[ Docs](https://github.com/stfalcon-studio/DoctrineRedisCacheBundle)[ RSS](/packages/stfalcon-studio-doctrine-redis-cache-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (15)Versions (16)Used By (0)

DoctrineRedisCacheBundle
========================

[](#doctrinerediscachebundle)

📦 Add custom namespace for doctrine cache pools.

[![Scrutinizer Quality Score](https://camo.githubusercontent.com/4ef94ddd188c5f7d0996b8b6c6b5ac0ff5c894b49b660c4d566610345bf43b9d/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f737466616c636f6e2d73747564696f2f446f637472696e655265646973436163686542756e646c652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/stfalcon-studio/DoctrineRedisCacheBundle/)[![Build Status](https://camo.githubusercontent.com/596beff596d6df694a1628546c02f5d462cb13fd998cf353030d1448895e714f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f737466616c636f6e2d73747564696f2f446f637472696e655265646973436163686542756e646c652f63692e79616d6c3f6272616e63683d6d61696e267374796c653d666c61742d737175617265)](https://github.com/stfalcon-studio/DoctrineRedisCacheBundle/actions?query=workflow%3ACI+branch%3Amain+)[![CodeCov](https://camo.githubusercontent.com/326792be03074fa34967e7479630c0f737b39ff79aab8ae70c503387cf81d6c3/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f737466616c636f6e2d73747564696f2f446f637472696e655265646973436163686542756e646c652e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/github/stfalcon-studio/DoctrineRedisCacheBundle)[![License](https://camo.githubusercontent.com/f7adb7b99d47406a9b55568bc4fb82dec0a1bfc0b60465a3f52c3d0a361647fb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f737466616c636f6e2d73747564696f2f646f637472696e652d72656469732d63616368652d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/stfalcon-studio/doctrine-redis-cache-bundle)[![Latest Stable Version](https://camo.githubusercontent.com/6ccdef7337e0a8bc80592bbe7bdf7c674273f8b69239d99b6129f1a3de96956f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f737466616c636f6e2d73747564696f2f646f637472696e652d72656469732d63616368652d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/stfalcon-studio/doctrine-redis-cache-bundle)[![Total Downloads](https://camo.githubusercontent.com/71d6fd27ab56005fdc89f0e5cc648338659144f30397649cd9e70244dace0bbc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f737466616c636f6e2d73747564696f2f646f637472696e652d72656469732d63616368652d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/stfalcon-studio/doctrine-redis-cache-bundle)[![StyleCI](https://camo.githubusercontent.com/865b1903e403dd44600cc291207e2814c030875e31c413dc5d91091cfaabc1e7/68747470733a2f2f7374796c6563692e696f2f7265706f732f3230303138383439362f736869656c643f7374796c653d666c61742d737175617265)](https://styleci.io/repos/200188496)

Problem Solved By This Bundle
-----------------------------

[](#problem-solved-by-this-bundle)

When you use Redis as cache provider to store Doctrine *query/metadata/result/second level* cache, Doctrine generates unique keys for each cache item. When you change your database schema, create a new migration (Doctrine migration) and then deploy it to production, you have to clean your Doctrine cache after deploy. Doctrine has console commands to clean any type of cache and they work well. But if during the cache flushing, you have already running script (long running console/cron task or consumer) it still uses old schema info which can conflict with your new schema. In this case this script can regenerate cache (because it has been already flushed) with old schema metadata, query, result etc.

To prevent this problem, we add a custom **namespace** for each selected cache pool. This **namespace** is a name of the last migration version. For example, you deploy the first version of your project to production. Last migration version is `1` so all keys in cache will have prefix `[1]` (e.g. `[1]hash_by_doctrine`). Then you modify your schema, generate a new migration (version `2`) and deploy it to production. Old running script will still use and generate keys with prefix `[1]`, but new scripts will begin to use fresh prefix `[2]` and don't conflict with previous prefix.

After that you can stop or rerun old script. And after rerun they will use a new prefix and you can clean cache entries with the previous prefix.

Installation
------------

[](#installation)

`composer req stfalcon-studio/doctrine-redis-cache-bundle`

#### Check the `config/bundles.php` file

[](#check-the-configbundlesphp-file)

By default Symfony Flex will add this bundle to the `config/bundles.php` file. But in case when you ignored `contrib-recipe` during bundle installation it would not be added. In this case add the bundle manually.

```
# config/bundles.php

return [
    // Other bundles...
    StfalconStudio\DoctrineRedisCacheBundle\StfalconStudioDoctrineRedisCacheBundle::class => ['all' => true],
    // Other bundles...
];
```

### Example of possible cache pool configuration

[](#example-of-possible-cache-pool-configuration)

```
framework:
    cache:
        default_redis_provider: snc_redis.default
        pools:
            doctrine.result_cache_pool:
                adapter: cache.adapter.redis
                provider: snc_redis.doctrine_result_cache
            doctrine.metadata_cache_pool:
                adapter: cache.adapter.redis
                provider: snc_redis.doctrine_metadata_cache
            doctrine.query_cache_pool:
                adapter: cache.adapter.redis
                provider: snc_redis.doctrine_query_cache
```

### Bundle configuration

[](#bundle-configuration)

```
stfalcon_studio_doctrine_redis_cache:
    cache_pools:
        - 'doctrine.query_cache_pool'
        - 'doctrine.metadata_cache_pool'
        - 'doctrine.result_cache_pool'
```

Contributing
------------

[](#contributing)

Read the [CONTRIBUTING](https://github.com/stfalcon-studio/DoctrineRedisCacheBundle/blob/master/.github/CONTRIBUTING.md) file.

###  Health Score

59

—

FairBetter than 99% of packages

Maintenance80

Actively maintained with recent releases

Popularity39

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity84

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 97.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~182 days

Recently: every ~334 days

Total

14

Last Release

104d ago

Major Versions

1.3.1 → 2.0.02022-01-23

2.1.1 → 3.0.02024-02-12

3.1.0 → 4.0.02026-02-03

PHP version history (7 changes)1.0.0PHP &gt;=7.1.3

1.1.0PHP &gt;=7.2.5

1.2.0PHP &gt;=7.3

2.0.0PHP &gt;=7.4

2.1.0PHP &gt;=8.1

3.0.0PHP &gt;=8.2

4.0.0PHP &gt;=8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/159215?v=4)[Stepan Tanasiychuk](/maintainers/stfalcon)[@stfalcon](https://github.com/stfalcon)

![](https://avatars.githubusercontent.com/u/815865?v=4)[Artem Henvald](/maintainers/fre5h)[@fre5h](https://github.com/fre5h)

---

Top Contributors

[![fre5h](https://avatars.githubusercontent.com/u/815865?v=4)](https://github.com/fre5h "fre5h (34 commits)")[![rela589n](https://avatars.githubusercontent.com/u/41589422?v=4)](https://github.com/rela589n "rela589n (1 commits)")

---

Tags

cachedoctrinedoctrine-migrationspredissymfonysymfony-bundlesymfonybundledoctrinerediscachecache pool

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/stfalcon-studio-doctrine-redis-cache-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/stfalcon-studio-doctrine-redis-cache-bundle/health.svg)](https://phpackages.com/packages/stfalcon-studio-doctrine-redis-cache-bundle)
```

###  Alternatives

[kreait/firebase-bundle

Symfony Bundle for the Firebase Admin SDK

1534.7M2](/packages/kreait-firebase-bundle)[sonata-project/doctrine-orm-admin-bundle

Integrate Doctrine ORM into the SonataAdminBundle

46117.7M155](/packages/sonata-project-doctrine-orm-admin-bundle)[fresh/doctrine-enum-bundle

Provides support of ENUM type for Doctrine2 in Symfony applications.

4636.8M12](/packages/fresh-doctrine-enum-bundle)[onurb/doctrine-yuml-bundle

Symfony Bundle to visualize the mapping of your entities with Yuml

4198.6k](/packages/onurb-doctrine-yuml-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
