FOUR-20532 clear cache by pattern by devmiguelangel · Pull Request #7795 · ProcessMaker/processmaker
Issue & Reproduction Steps
Clear settings cache by pattern
Solution
- List the changes you've introduced to solve the issue.
Related Tickets & Packages
Code Review Checklist
- I have pulled this code locally and tested it on my instance, along with any associated packages.
- This code adheres to ProcessMaker Coding Guidelines.
- This code includes a unit test or an E2E test that tests its functionality, or is covered by an existing test.
- This solution fixes the bug reported in the original ticket.
- This solution does not alter the expected output of a component in a way that would break existing Processes.
- This solution does not implement any breaking changes that would invalidate documentation or cause existing Processes to fail.
- This solution has been tested with enterprise packages that rely on its functionality and does not introduce bugs in those packages.
- This code does not duplicate functionality that already exists in the framework or in ProcessMaker.
- This ticket conforms to the PRD associated with this part of ProcessMaker.
| public function __construct(CacheManager $cacheManager) | ||
| { | ||
| $this->cacheManager = $cacheManager; | ||
| $driver = env('CACHE_SETTING_DRIVER') ?? env('CACHE_DRIVER', 'redis'); |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use config instead of env.
In a production environment the .env file is not loaded, only the config from cache.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was fixed
| // get the connection name from the cache manager | ||
| $connection = $this->cacheManager->connection()->getName(); | ||
| // Get all keys | ||
| $keys = Redis::connection($connection)->keys('*'); |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the cache drive is not Redis?
Consider to close the Settings driver CACHE_SETTING_DRIVER to be always cache_settings or implement a general logic for other types of drivers.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A validation was added
| { | ||
| \SettingCache::clear(); | ||
|
|
||
| putenv('CACHE_SETTING_DRIVER'); |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider to use config instead of env
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was fixed
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters