From d9e24693289f8731e28e63c55c884a638874db10 Mon Sep 17 00:00:00 2001 From: Martin Kluska Date: Mon, 29 Jul 2024 19:18:01 +0200 Subject: [PATCH] fix(Context): Fix deleting cache in context and drop tags usage by default BREAKING CHANGE: Drop default tag for context cache - Laravel offical recommendation is not to use tags with redis --- src/Context/Services/ContextService.php | 10 ++++++---- tests/Feature/Context/Services/ContextServiceTest.php | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Context/Services/ContextService.php b/src/Context/Services/ContextService.php index 8e4e23f0..99f0006a 100644 --- a/src/Context/Services/ContextService.php +++ b/src/Context/Services/ContextService.php @@ -19,8 +19,6 @@ class ContextService implements ContextServiceContract { - protected const TAG = 'context'; - public function __construct( private readonly CacheMeServiceContract $cacheMeManager, private readonly ImplementsService $implementsService @@ -31,7 +29,11 @@ public function delete(AbstractContext $context): void { $fullCacheKey = $this->getCacheKey($context); - $this->cacheMeManager->delete(key: $fullCacheKey, strategy: $this->cacheStrategy($context)); + $this->cacheMeManager->delete( + key: $fullCacheKey, + tags: $this->getTags($context), + strategy: $this->cacheStrategy($context) + ); } /** @@ -99,7 +101,7 @@ protected function cacheStrategy(AbstractContext $context): CacheMeStrategy protected function getTags(AbstractContext $context): array { - $tags = [self::TAG]; + $tags = []; if ($this->implementsService->check($context, UseCacheWithTags::class) === false) { return $tags; diff --git a/tests/Feature/Context/Services/ContextServiceTest.php b/tests/Feature/Context/Services/ContextServiceTest.php index 5687cd13..b56f5ebc 100644 --- a/tests/Feature/Context/Services/ContextServiceTest.php +++ b/tests/Feature/Context/Services/ContextServiceTest.php @@ -76,7 +76,7 @@ public function assert( cacheMeManager: new CacheMeServiceContractAssert(get: [ new CacheMeServiceContractGetExpectation( key: $expectedCacheKey, - tags: ['context'], + tags: [], minutes: 3600, strategy: CacheMeStrategy::Memory, callGetValueHook: $callHook