Skip to content

Commit ef48b0b

Browse files
authored
[12.x] Fix unable to flush redis tagged cache when prefix contains - instead of _ (#57927)
* [Regression] Unable to flush redis tagged cache when prefix contains `-` instead of `_` Signed-off-by: Mior Muhammad Zaki <[email protected]> * Fix implementation Signed-off-by: Mior Muhammad Zaki <[email protected]> --------- Signed-off-by: Mior Muhammad Zaki <[email protected]>
1 parent 33aa4d4 commit ef48b0b

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/Illuminate/Cache/RedisTaggedCache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public function flush()
156156
$script,
157157
count($keysToBeDeleted),
158158
...$keysToBeDeleted,
159-
...[$cachePrefix, ...$cacheTags]
159+
...[str_replace('-', '%-', $cachePrefix), ...$cacheTags]
160160
);
161161
}
162162

tests/Integration/Cache/RedisStoreTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Illuminate\Support\Sleep;
1111
use Mockery as m;
1212
use Orchestra\Testbench\TestCase;
13+
use PHPUnit\Framework\Attributes\TestWith;
1314

1415
class RedisStoreTest extends TestCase
1516
{
@@ -93,8 +94,12 @@ public function testItCanExpireWithZeroTTL()
9394
$this->assertNull($value);
9495
}
9596

96-
public function testTagsCanBeAccessed()
97+
#[TestWith(['laravel_cache_'])]
98+
#[TestWith(['laravel-cache-'])]
99+
public function testTagsCanBeAccessed(string $cachePrefix)
97100
{
101+
config(['cache.prefix' => $cachePrefix]);
102+
98103
Cache::store('redis')->clear();
99104

100105
Cache::store('redis')->tags(['people', 'author'])->put('name', 'Sally', 5);

0 commit comments

Comments
 (0)