Skip to content

Commit

Permalink
Update cache key
Browse files Browse the repository at this point in the history
  • Loading branch information
enjinabner committed Jul 6, 2023
1 parent 33023e6 commit a7a192d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/CoreServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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())
);
}

Expand All @@ -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())
);
}

Expand Down
2 changes: 2 additions & 0 deletions src/Enums/Global/PlatformCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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'));
}
Expand Down

0 comments on commit a7a192d

Please sign in to comment.