FOUR-20532 clear cache by pattern by devmiguelangel · Pull Request #7795 · ProcessMaker/processmaker

@devmiguelangel

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

caleeli

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

caleeli

// 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

caleeli

{
\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

julceslauhub

Choose a reason for hiding this comment

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

Approved

@devmiguelangel

@processmaker-sonarqube

caleeli