mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
cache
This commit is contained in:
@@ -1299,6 +1299,7 @@ App::get('/v1/storage/buckets/:bucketId/files/:fileId/view')
|
||||
$size = $deviceForFiles->getFileSize($path);
|
||||
if ($size > APP_STORAGE_READ_BUFFER) {
|
||||
for ($i = 0; $i < ceil($size / MAX_OUTPUT_CHUNK_SIZE); $i++) {
|
||||
|
||||
$response->chunk(
|
||||
$deviceForFiles->read(
|
||||
$path,
|
||||
|
||||
@@ -473,7 +473,9 @@ App::init()
|
||||
);
|
||||
$timestamp = 60 * 60 * 24 * 30;
|
||||
$data = $cache->load($key, $timestamp);
|
||||
|
||||
if (!empty($data) && !$cacheLog->isEmpty()) {
|
||||
|
||||
$parts = explode('/', $cacheLog->getAttribute('resourceType'));
|
||||
$type = $parts[0] ?? null;
|
||||
|
||||
@@ -718,7 +720,7 @@ App::shutdown()
|
||||
if ($useCache) {
|
||||
$resource = $resourceType = null;
|
||||
$data = $response->getPayload();
|
||||
|
||||
var_dump($response->getHeaders());
|
||||
if (!empty($data['payload'])) {
|
||||
|
||||
$pattern = $route->getLabel('cache.resource', null);
|
||||
@@ -735,6 +737,7 @@ App::shutdown()
|
||||
if(!empty($request->getRangeStart())) $keyParams .= '*'.$request->getRangeStart();
|
||||
if(!empty($request->getRangeEnd())) $keyParams .= '*'.$request->getRangeEnd();
|
||||
$keyParams .= '*'. APP_CACHE_BUSTER;
|
||||
|
||||
$key = md5($keyParams);
|
||||
$signature = md5($data['payload']);
|
||||
$cacheLog = Authorization::skip(fn () => $dbForProject->getDocument('cache', $key));
|
||||
|
||||
@@ -694,6 +694,48 @@ class Response extends SwooleResponse
|
||||
$this->send($body);
|
||||
}
|
||||
|
||||
/**
|
||||
* Output response
|
||||
*
|
||||
* Generate HTTP response output including the response header (+cookies) and body and prints them.
|
||||
*
|
||||
* @param string $body
|
||||
* @param bool $end
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function bla(string $body = '', bool $end = false): void
|
||||
{
|
||||
if ($this->sent) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($end) {
|
||||
$this->sent = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->addHeader('X-Debug-Speed', (string) (microtime(true) - $this->startTime));
|
||||
|
||||
$this
|
||||
->appendCookies()
|
||||
->appendHeaders();
|
||||
|
||||
$this->payload = [
|
||||
'payload' => $body
|
||||
];
|
||||
|
||||
if (!$this->disablePayload) {
|
||||
$this->write($body);
|
||||
if ($end) {
|
||||
$this->disablePayload();
|
||||
$this->end();
|
||||
}
|
||||
} else {
|
||||
$this->end();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* YAML
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user