{"id":20447218,"url":"https://github.com/stfalcon-studio/doctrinerediscachebundle","last_synced_at":"2025-04-13T01:07:23.638Z","repository":{"id":35044863,"uuid":"200188496","full_name":"stfalcon-studio/DoctrineRedisCacheBundle","owner":"stfalcon-studio","description":":package: Add custom namespace for doctrine cache pools.","archived":false,"fork":false,"pushed_at":"2024-05-31T15:52:34.000Z","size":51,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-10T18:06:43.329Z","etag":null,"topics":["cache","doctrine","doctrine-migrations","predis","symfony","symfony-bundle"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stfalcon-studio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-02T07:35:09.000Z","updated_at":"2024-05-31T15:52:02.000Z","dependencies_parsed_at":"2024-01-02T08:42:20.980Z","dependency_job_id":"84d2b710-5f3c-4214-af5e-9949eab77ac4","html_url":"https://github.com/stfalcon-studio/DoctrineRedisCacheBundle","commit_stats":{"total_commits":28,"total_committers":1,"mean_commits":28.0,"dds":0.0,"last_synced_commit":"c84e6e704017e2fb6d1ecb8cb2d906998c0241d1"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stfalcon-studio%2FDoctrineRedisCacheBundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stfalcon-studio%2FDoctrineRedisCacheBundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stfalcon-studio%2FDoctrineRedisCacheBundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stfalcon-studio%2FDoctrineRedisCacheBundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stfalcon-studio","download_url":"https://codeload.github.com/stfalcon-studio/DoctrineRedisCacheBundle/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650773,"owners_count":21139681,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cache","doctrine","doctrine-migrations","predis","symfony","symfony-bundle"],"created_at":"2024-11-15T10:25:14.174Z","updated_at":"2025-04-13T01:07:23.619Z","avatar_url":"https://github.com/stfalcon-studio.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DoctrineRedisCacheBundle\n\n:package: Add custom namespace for doctrine cache pools.\n\n[![Scrutinizer Quality Score](https://img.shields.io/scrutinizer/g/stfalcon-studio/DoctrineRedisCacheBundle.svg?style=flat-square)](https://scrutinizer-ci.com/g/stfalcon-studio/DoctrineRedisCacheBundle/)\n[![Build Status](https://img.shields.io/github/actions/workflow/status/stfalcon-studio/DoctrineRedisCacheBundle/ci.yaml?branch=main\u0026style=flat-square)](https://github.com/stfalcon-studio/DoctrineRedisCacheBundle/actions?query=workflow%3ACI+branch%3Amain+)\n[![CodeCov](https://img.shields.io/codecov/c/github/stfalcon-studio/DoctrineRedisCacheBundle.svg?style=flat-square)](https://codecov.io/github/stfalcon-studio/DoctrineRedisCacheBundle)\n[![License](https://img.shields.io/packagist/l/stfalcon-studio/doctrine-redis-cache-bundle.svg?style=flat-square)](https://packagist.org/packages/stfalcon-studio/doctrine-redis-cache-bundle)\n[![Latest Stable Version](https://img.shields.io/packagist/v/stfalcon-studio/doctrine-redis-cache-bundle.svg?style=flat-square)](https://packagist.org/packages/stfalcon-studio/doctrine-redis-cache-bundle)\n[![Total Downloads](https://img.shields.io/packagist/dt/stfalcon-studio/doctrine-redis-cache-bundle.svg?style=flat-square)](https://packagist.org/packages/stfalcon-studio/doctrine-redis-cache-bundle)\n[![StyleCI](https://styleci.io/repos/200188496/shield?style=flat-square)](https://styleci.io/repos/200188496)\n\n## Problem Solved By This Bundle\n\nWhen you use Redis as cache provider to store Doctrine _query/metadata/result/second level_ cache, Doctrine generates unique keys for each cache item.\nWhen 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.\nDoctrine 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.\nIn this case this script can regenerate cache (because it has been already flushed) with old schema metadata, query, result etc.\n\nTo prevent this problem, we add a custom **namespace** for each selected cache pool. This **namespace** is a name of the last migration version.\nFor 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`).\nThen 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.\n\nAfter 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.\n\n## Installation\n\n```composer req stfalcon-studio/doctrine-redis-cache-bundle```\n\n#### Check the `config/bundles.php` file\n\nBy default Symfony Flex will add this bundle to the `config/bundles.php` file.\nBut in case when you ignored `contrib-recipe` during bundle installation it would not be added. In this case add the bundle manually.\n\n```php\n# config/bundles.php\n\nreturn [\n    // Other bundles...\n    StfalconStudio\\DoctrineRedisCacheBundle\\StfalconStudioDoctrineRedisCacheBundle::class =\u003e ['all' =\u003e true],\n    // Other bundles...\n];\n```\n\n### Example of possible cache pool configuration\n\n```yaml\nframework:\n    cache:\n        default_redis_provider: snc_redis.default\n        pools:\n            doctrine.result_cache_pool:\n                adapter: cache.adapter.redis\n                provider: snc_redis.doctrine_result_cache\n            doctrine.metadata_cache_pool:\n                adapter: cache.adapter.redis\n                provider: snc_redis.doctrine_metadata_cache\n            doctrine.query_cache_pool:\n                adapter: cache.adapter.redis\n                provider: snc_redis.doctrine_query_cache\n```\n\n### Bundle configuration\n\n```yaml\nstfalcon_studio_doctrine_redis_cache:\n    cache_pools:\n        - 'doctrine.query_cache_pool'\n        - 'doctrine.metadata_cache_pool'\n        - 'doctrine.result_cache_pool'\n\n```\n\n## Contributing\n\nRead the [CONTRIBUTING](https://github.com/stfalcon-studio/DoctrineRedisCacheBundle/blob/master/.github/CONTRIBUTING.md) file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstfalcon-studio%2Fdoctrinerediscachebundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstfalcon-studio%2Fdoctrinerediscachebundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstfalcon-studio%2Fdoctrinerediscachebundle/lists"}