mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
Migrated cache buster to a script
This commit is contained in:
1 parent
1409ea4dbf
commit
ecbc9aecb3
6 files changed
+68
-42
No files matched your search
@@ -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
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user