-
Notifications
You must be signed in to change notification settings - Fork 227
FOUR-20532 clear cache by pattern #7795
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
8ba0527
to
f3021b1
Compare
|
||
public function __construct(CacheManager $cacheManager) | ||
{ | ||
$this->cacheManager = $cacheManager; | ||
$driver = env('CACHE_SETTING_DRIVER') ?? env('CACHE_DRIVER', 'redis'); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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('*'); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved
…prove clearBy method
8db2885
to
2c61caa
Compare
|
Issue & Reproduction Steps
Clear settings cache by pattern
Solution
Related Tickets & Packages
FOUR-20532
FOUR-20908
Code Review Checklist