Skip to content

FOUR-20532 clear cache by pattern#7795

Merged
caleeli merged 3 commits intoepic/FOUR-20326from
FOUR-20532
Dec 6, 2024
Merged

FOUR-20532 clear cache by pattern#7795
caleeli merged 3 commits intoepic/FOUR-20326from
FOUR-20532

Conversation

@devmiguelangel
Copy link
Copy Markdown
Contributor

@devmiguelangel devmiguelangel commented Dec 5, 2024

Issue & Reproduction Steps

Clear settings cache by pattern

Solution

  • List the changes you've introduced to solve the issue.

Related Tickets & Packages

FOUR-20532
FOUR-20908

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.

@devmiguelangel devmiguelangel self-assigned this Dec 5, 2024
public function __construct(CacheManager $cacheManager)
{
$this->cacheManager = $cacheManager;
$driver = env('CACHE_SETTING_DRIVER') ?? env('CACHE_DRIVER', 'redis');
Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

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('*');
Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

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');
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was fixed

@caleeli caleeli requested a review from julceslauhub December 5, 2024 15:21
Copy link
Copy Markdown
Contributor

@julceslauhub julceslauhub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

@processmaker-sonarqube
Copy link
Copy Markdown

Quality Gate passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

@caleeli caleeli self-requested a review December 6, 2024 12:42
@caleeli caleeli merged commit e1e6b4e into epic/FOUR-20326 Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants