@@ -89,6 +89,8 @@ public static function setConfig($key, $config = null): void
8989 }
9090
9191 return ;
92+ } elseif (is_array ($ key )) {
93+ throw new LogicException ('If config is not null, key must be a string. ' );
9294 }
9395
9496 if (isset (static ::$ _config [$ key ])) {
@@ -127,7 +129,9 @@ public static function setConfig($key, $config = null): void
127129
128130 $ cacheConfig = array_merge ($ cacheDefaults , $ config ['uniqueCache ' ]);
129131
130- Cache::setConfig ('Cake/Queue.queueUnique ' , $ cacheConfig );
132+ $ config ['uniqueCacheKey ' ] = "Cake/Queue.queueUnique. {$ key }" ;
133+
134+ Cache::setConfig ($ config ['uniqueCacheKey ' ], $ cacheConfig );
131135 }
132136
133137 /** @psalm-suppress InvalidPropertyAssignmentValue */
@@ -228,15 +232,15 @@ public static function push($className, array $data = [], array $options = []):
228232
229233 /** @psalm-suppress InvalidPropertyFetch */
230234 if (!empty ($ class ::$ shouldBeUnique )) {
231- if (!Cache:: getConfig ( ' Cake/Queue.queueUnique ' )) {
235+ if (empty ( $ config [ ' uniqueCache ' ] )) {
232236 throw new InvalidArgumentException (
233237 "$ class:: \$shouldBeUnique is set to `true` but `uniqueCache` configuration is missing. "
234238 );
235239 }
236240
237241 $ uniqueId = static ::getUniqueId ($ class , $ method , $ data );
238242
239- if (Cache::read ($ uniqueId , ' Cake/Queue.queueUnique ' )) {
243+ if (Cache::read ($ uniqueId , $ config [ ' uniqueCacheKey ' ] )) {
240244 if ($ logger ) {
241245 $ logger ->debug (
242246 "An identical instance of $ class already exists on the queue. This push will be ignored. "
@@ -279,7 +283,7 @@ public static function push($className, array $data = [], array $options = []):
279283 if (!empty ($ class ::$ shouldBeUnique )) {
280284 $ uniqueId = static ::getUniqueId ($ class , $ method , $ data );
281285
282- Cache::add ($ uniqueId , true , ' Cake/Queue.queueUnique ' );
286+ Cache::add ($ uniqueId , true , $ config [ ' uniqueCacheKey ' ] );
283287 }
284288 }
285289
0 commit comments