refactor: implement centralized cache key management and add utility traits for vCenter SSH operations.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
namespace App\Repositories\vCenter;
|
||||
|
||||
use App\Repositories\BaseCachedRepository;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use App\Support\Cache\CacheKey;
|
||||
|
||||
class vCenterCachedRepository extends BaseCachedRepository implements vCenterRepositoryInterface
|
||||
{
|
||||
@@ -31,26 +31,15 @@ class vCenterCachedRepository extends BaseCachedRepository implements vCenterRep
|
||||
->filter($data, $relationships, $withCount, $select, $returnQuery);
|
||||
}
|
||||
|
||||
$cacheKey = $this->getCacheKey(md5(json_encode([
|
||||
'filter' => compact('data', 'relationships', 'withCount', 'select')
|
||||
])));
|
||||
|
||||
return Cache::remember(
|
||||
$cacheKey,
|
||||
$this->cacheTime,
|
||||
fn() =>
|
||||
$this->vCenterRepository
|
||||
->filter($data, $relationships, $withCount, $select, $returnQuery)
|
||||
return $this->rememberFilter(
|
||||
compact('data', 'relationships', 'withCount', 'select'),
|
||||
fn() => $this->vCenterRepository->filter($data, $relationships, $withCount, $select, $returnQuery)
|
||||
);
|
||||
}
|
||||
public function findByName(string $name = '')
|
||||
{
|
||||
$cacheKey = $this->getCacheKey(md5(json_encode([
|
||||
'findByName' => [
|
||||
'name' => $name
|
||||
]
|
||||
])));
|
||||
return Cache::remember($cacheKey, $this->cacheTime, function () use ($name) {
|
||||
$cacheKey = CacheKey::build($this->getModuleName(), 'find-by-name', ['name' => $name]);
|
||||
return $this->cache->remember($cacheKey, function () use ($name) {
|
||||
return $this->vCenterRepository->findByName($name);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user