Migrated cache buster to a script

This commit is contained in:
Matej Bačo committed 2023-05-02 13:21:08 +02:00
1 parent 1409ea4dbf
commit ecbc9aecb3
6 files changed
+68 -42

No files matched your search

-36
View File
@@ -438,42 +438,6 @@ App::shutdown()
$database->trigger();
}
/**
* Cache Buster
*/
$bustCache = $route->getLabel('cacheBuster', false);
if ($bustCache) {
$payload = $response->getPayload();
if (!empty($payload)) {
$resources = [];
$patterns = $route->getLabel('cacheBuster.resource', []);
if (!empty($patterns)) {
foreach ($patterns as $pattern) {
$resources[] = $parseLabel($pattern, $responsePayload, $requestParams, $user);
}
}
$caches = Authorization::skip(fn () => $dbForProject->find('cache', [
Query::equal('resource', $resources),
Query::limit(100)
]));
foreach ($caches as $cache) {
$key = $cache->getId();
$cache = new Cache(
new Filesystem(APP_STORAGE_CACHE . DIRECTORY_SEPARATOR . 'app-' . $project->getId())
);
$cache->purge($key);
Authorization::skip(fn () => $dbForProject->deleteDocument('cache', $cache->getId()));
}
}
}
/**
* Cache label
*/