mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
perf(storage): refresh streamed cache hits with touch
This commit is contained in:
@@ -714,18 +714,13 @@ Http::init()
|
||||
}
|
||||
}
|
||||
|
||||
$cachedPayload = null;
|
||||
$accessedAt = $cacheLog->getAttribute('accessedAt', '');
|
||||
if (DateTime::formatTz(DateTime::addSeconds(new \DateTime(), -APP_CACHE_UPDATE)) > $accessedAt) {
|
||||
$authorization->skip(fn () => $dbForProject->updateDocument('cache', $cacheLog->getId(), new Document([
|
||||
'accessedAt' => DateTime::now(),
|
||||
])));
|
||||
$cachedPayload = \stream_get_contents($data);
|
||||
if ($cachedPayload === false) {
|
||||
throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Failed to read cached response stream');
|
||||
}
|
||||
// Refresh the filesystem file's mtime so TTL-based expiry in cache->load() stays valid
|
||||
$cache->save($key, $cachedPayload);
|
||||
$cache->touch($key);
|
||||
}
|
||||
|
||||
$response
|
||||
@@ -735,12 +730,6 @@ Http::init()
|
||||
$storageCacheOperationsCounter->add(1, ['result' => 'hit']);
|
||||
if (! $isImageTransformation || ! $isDisabled) {
|
||||
Span::add('storage.cache.hit', true);
|
||||
if ($cachedPayload !== null) {
|
||||
\fclose($data);
|
||||
$response->send($cachedPayload);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
while (! \feof($data)) {
|
||||
$chunk = \fread($data, MAX_OUTPUT_CHUNK_SIZE);
|
||||
|
||||
Generated
+6
-6
@@ -3614,16 +3614,16 @@
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/cache",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/cache.git",
|
||||
"reference": "d36f9050c39c02e09a7763389c9e71258e74af1f"
|
||||
"reference": "ef52a04e8bfa314c621e3d3326ffcf50db3dfdfa"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/cache/zipball/d36f9050c39c02e09a7763389c9e71258e74af1f",
|
||||
"reference": "d36f9050c39c02e09a7763389c9e71258e74af1f",
|
||||
"url": "https://api.github.com/repos/utopia-php/cache/zipball/ef52a04e8bfa314c621e3d3326ffcf50db3dfdfa",
|
||||
"reference": "ef52a04e8bfa314c621e3d3326ffcf50db3dfdfa",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -3660,9 +3660,9 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/cache/issues",
|
||||
"source": "https://github.com/utopia-php/cache/tree/1.0.2"
|
||||
"source": "https://github.com/utopia-php/cache/tree/1.0.3"
|
||||
},
|
||||
"time": "2026-05-08T11:40:20+00:00"
|
||||
"time": "2026-05-11T11:02:13+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/cli",
|
||||
|
||||
Reference in New Issue
Block a user