Skip to content

Conversation

@sheldonreiff
Copy link
Contributor

Prevents an exception when multiple configs are set with uniqueCache configured.

Fixes #113

@sheldonreiff sheldonreiff force-pushed the use-unique-name-for-cache-configurations branch from 837af4c to 90590d7 Compare March 10, 2023 22:23
@sheldonreiff sheldonreiff force-pushed the use-unique-name-for-cache-configurations branch from 90590d7 to e87fe35 Compare March 10, 2023 23:03
@markstory markstory added this to the 1.0.0 milestone Mar 13, 2023
$cacheConfig = array_merge($cacheDefaults, $config['uniqueCache']);

Cache::setConfig('Cake/Queue.queueUnique', $cacheConfig);
$config['uniqueCacheKey'] = "Cake/Queue.queueUnique.{$key}";
Copy link
Member

Choose a reason for hiding this comment

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

Couldn't this be put into the defaults so that userland code can define it if they really need to?

$cacheDefaults` = [
  'duration' => '+24 hours',
  'uniqueCacheKey' => "Cake/Queue.queueUnique.{$key}"
];

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The whole array nested under uniqueCache is passed directly through to Cache::setConfig(), so maybe that would be slightly confusing that uniqueCacheKey isn't part of the cache config? We could bump it up a level though and let it be configurable as part of the main config. So configuring the unique cache would look like this:

'uniqueCacheKey' => 'someCustomKey', // (optional)
'uniqueCache' => [
    'engine' => 'File',
],

Copy link
Member

Choose a reason for hiding this comment

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

maybe that would be slightly confusing that uniqueCacheKey isn't part of the cache config?

Yeah that would be odd. Lets roll with what you have so far. If we come up with use-cases that require custom cache key configuration control we can revisit then.

@markstory markstory merged commit 75db394 into cakephp:master Mar 14, 2023
@sheldonreiff sheldonreiff deleted the use-unique-name-for-cache-configurations branch March 17, 2023 17:31
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.

QueueManager Fails when Multiple Queue Configs Contain uniqueCache Key

2 participants