cache deleteById to deleteByGroup
This commit is contained in:
parent
a37fee2d16
commit
b7aab21698
1 changed files with 20 additions and 19 deletions
|
@ -136,30 +136,31 @@ class DeletesV1 extends Worker
|
||||||
*/
|
*/
|
||||||
protected function deleteCacheByResource(Document $project, string $resource): void
|
protected function deleteCacheByResource(Document $project, string $resource): void
|
||||||
{
|
{
|
||||||
|
|
||||||
$projectId = $project->getId();
|
$projectId = $project->getId();
|
||||||
$dbForProject = $this->getProjectDB($projectId);
|
$dbForProject = $this->getProjectDB($project);
|
||||||
$document = $dbForProject->findOne('cache', [Query::equal('resource', [$resource])]);
|
|
||||||
|
|
||||||
if ($document) {
|
$cache = new Cache(
|
||||||
$cache = new Cache(
|
new Filesystem(APP_STORAGE_CACHE . DIRECTORY_SEPARATOR . 'app-' . $projectId)
|
||||||
new Filesystem(APP_STORAGE_CACHE . DIRECTORY_SEPARATOR . 'app-' . $projectId)
|
);
|
||||||
);
|
|
||||||
|
|
||||||
$this->deleteById(
|
$query = [
|
||||||
$document,
|
Query::equal('resource', [$resource])
|
||||||
$dbForProject,
|
];
|
||||||
function ($document) use ($cache, $projectId) {
|
|
||||||
$path = APP_STORAGE_CACHE . DIRECTORY_SEPARATOR . 'app-' . $projectId . DIRECTORY_SEPARATOR . $document->getId();
|
|
||||||
|
|
||||||
if ($cache->purge($document->getId())) {
|
$this->deleteByGroup(
|
||||||
Console::success('Deleting cache file: ' . $path);
|
'cache',
|
||||||
} else {
|
$query,
|
||||||
Console::error('Failed to delete cache file: ' . $path);
|
$dbForProject,
|
||||||
}
|
function (Document $document) use ($cache, $projectId) {
|
||||||
|
$path = APP_STORAGE_CACHE . DIRECTORY_SEPARATOR . 'app-' . $projectId . DIRECTORY_SEPARATOR . $document->getId();
|
||||||
|
|
||||||
|
if ($cache->purge($document->getId())) {
|
||||||
|
Console::success('Deleting cache file: ' . $path);
|
||||||
|
} else {
|
||||||
|
Console::error('Failed to delete cache file: ' . $path);
|
||||||
}
|
}
|
||||||
);
|
}
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue