Compare commits

...
Author SHA1 Message Date
shimon e416719f66 cache deleteById to deleteByGroup 2023-07-14 18:27:26 +03:00
shimon 5267dd86f1 cache deleteById to deleteByGroup 2023-07-13 14:08:42 +03:00
+20 -18
View File
@@ -130,7 +130,7 @@ class DeletesV1 extends Worker
}
/**
* @throws Exception
* @throws Exception|Throwable
*/
protected function deleteSchedules(string $datetime): void
{
@@ -170,27 +170,29 @@ class DeletesV1 extends Worker
{
$projectId = $project->getId();
$dbForProject = $this->getProjectDB($project);
$document = $dbForProject->findOne('cache', [Query::equal('resource', [$resource])]);
if ($document) {
$cache = new Cache(
new Filesystem(APP_STORAGE_CACHE . DIRECTORY_SEPARATOR . 'app-' . $projectId)
);
$cache = new Cache(
new Filesystem(APP_STORAGE_CACHE . DIRECTORY_SEPARATOR . 'app-' . $projectId)
);
$this->deleteById(
$document,
$dbForProject,
function ($document) use ($cache, $projectId) {
$path = APP_STORAGE_CACHE . DIRECTORY_SEPARATOR . 'app-' . $projectId . DIRECTORY_SEPARATOR . $document->getId();
$query = [
Query::equal('resource', [$resource])
];
if ($cache->purge($document->getId())) {
Console::success('Deleting cache file: ' . $path);
} else {
Console::error('Failed to delete cache file: ' . $path);
}
$this->deleteByGroup(
'cache',
$query,
$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);
}
);
}
}
);
}
/**