From a7a192d470ba61bc27c3da6e3ae00c89cc2775cb Mon Sep 17 00:00:00 2001 From: Abner Tudtud Date: Thu, 6 Jul 2023 10:10:52 +0800 Subject: [PATCH] Update cache key --- src/CoreServiceProvider.php | 5 +++-- src/Enums/Global/PlatformCache.php | 2 ++ .../Schemas/Primary/Mutations/VerifyAccountMutation.php | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/CoreServiceProvider.php b/src/CoreServiceProvider.php index 863cbe7f..74764649 100644 --- a/src/CoreServiceProvider.php +++ b/src/CoreServiceProvider.php @@ -6,6 +6,7 @@ use Enjin\Platform\Commands\Ingest; use Enjin\Platform\Commands\Sync; use Enjin\Platform\Commands\Transactions; +use Enjin\Platform\Enums\Global\PlatformCache; use Enjin\Platform\Events\Substrate\Commands\PlatformSynced; use Enjin\Platform\Events\Substrate\Commands\PlatformSyncError; use Enjin\Platform\Events\Substrate\Commands\PlatformSyncing; @@ -90,7 +91,7 @@ public function boot() $totalCount = (int) Cache::remember( $this->toSql(), 6, - fn () => Cache::lock('enjin-platform.lock:' . $this->toSql())->get(fn () => $this->count()) + fn () => Cache::lock(PlatformCache::PAGINATION->key($this->toSql()))->get(fn () => $this->count()) ); } @@ -105,7 +106,7 @@ public function boot() $totalCount = (int) Cache::remember( $this->toSql(), 6, - fn () => Cache::lock('enjin-platform.lock:' . $this->toSql())->get(fn () => $this->count()) + fn () => Cache::lock(PlatformCache::PAGINATION->key($this->toSql()))->get(fn () => $this->count()) ); } diff --git a/src/Enums/Global/PlatformCache.php b/src/Enums/Global/PlatformCache.php index f166eefd..10bc677d 100644 --- a/src/Enums/Global/PlatformCache.php +++ b/src/Enums/Global/PlatformCache.php @@ -19,6 +19,8 @@ enum PlatformCache: string implements PlatformCacheable case BLOCK_EVENTS = 'blockEvents'; case BLOCK_EXTRINSICS = 'blockExtrinsics'; case SYNCING_IN_PROGRESS = 'syncingInProgress'; + case VERIFY_ACCOUNT = 'verifyAccount'; + case PAGINATION = 'pagination'; public function key(?string $suffix = null): string { diff --git a/src/GraphQL/Schemas/Primary/Mutations/VerifyAccountMutation.php b/src/GraphQL/Schemas/Primary/Mutations/VerifyAccountMutation.php index f351007f..4b9bffa7 100644 --- a/src/GraphQL/Schemas/Primary/Mutations/VerifyAccountMutation.php +++ b/src/GraphQL/Schemas/Primary/Mutations/VerifyAccountMutation.php @@ -3,6 +3,7 @@ namespace Enjin\Platform\GraphQL\Schemas\Primary\Mutations; use Closure; +use Enjin\Platform\Enums\Global\PlatformCache; use Enjin\Platform\Enums\Substrate\CryptoSignatureType; use Enjin\Platform\Exceptions\PlatformException; use Enjin\Platform\GraphQL\Schemas\Primary\Traits\InPrimarySchema; @@ -78,7 +79,7 @@ public function resolve( VerificationService $verificationService ): mixed { $key = "{$args['verificationId']}.{$args['account']}"; - $lock = Cache::lock('enjin-platform:verify-account-cache.' . $key, 5); + $lock = Cache::lock(PlatformCache::VERIFY_ACCOUNT->key($key), 5); if (!$lock->get()) { throw new PlatformException(__('enjin-platform::error.unable_to_process')); }