mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Timer::tick
This commit is contained in:
@@ -931,6 +931,7 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons
|
||||
if ($project->isEmpty()) {
|
||||
$user = new Document(['$id' => ID::custom(''), '$collection' => 'users']);
|
||||
} else {
|
||||
var_dump('Save cache invoked');
|
||||
$user = $dbForProject->getDocument('users', Auth::$unique);
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -5,6 +5,8 @@ require_once __DIR__ . '/../worker.php';
|
||||
|
||||
use Utopia\App;
|
||||
use Utopia\Cache\Cache;
|
||||
use Utopia\CLI\Console;
|
||||
use Utopia\Database\DateTime;
|
||||
use Utopia\Queue;
|
||||
use Utopia\Queue\Message;
|
||||
|
||||
@@ -18,12 +20,14 @@ $server->job()
|
||||
->inject('message')
|
||||
->inject('cache')
|
||||
->action(function (Message $message, Cache $cache) {
|
||||
|
||||
$time = DateTime::now();
|
||||
$payload = $message->getPayload()['value'];
|
||||
$cache->setDisableListeners(true);
|
||||
foreach ($payload['keys'] ?? [] as $key) {
|
||||
var_dump('purging -> ' . $key);
|
||||
var_dump($cache->purge($key));
|
||||
Console::info("[{$time}] Purging {$key}");
|
||||
$cache->purge($key);
|
||||
}
|
||||
$cache->setDisableListeners(false);
|
||||
});
|
||||
|
||||
$server
|
||||
@@ -36,6 +40,6 @@ $server
|
||||
|
||||
$server
|
||||
->workerStart(function () {
|
||||
echo "In region [" . App::getEnv('_APP_REGION', 'nyc1') . "] cache purging worker Started" . PHP_EOL;
|
||||
echo "In [" . App::getEnv('_APP_REGION', 'nyc1') . "] edge cache purging worker Started" . PHP_EOL;
|
||||
})
|
||||
->start();
|
||||
|
||||
@@ -63,7 +63,7 @@ function send(string $url, string $token, array $stack): array
|
||||
return $payload;
|
||||
}
|
||||
|
||||
sleep(2);
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
curl_close($ch);
|
||||
@@ -115,7 +115,7 @@ $server->job()
|
||||
->action(function (Message $message) use (&$stack, &$failures) {
|
||||
|
||||
$payload = $message->getPayload()['value'] ?? [];
|
||||
var_dump($message->getPayload());
|
||||
|
||||
if (!empty($payload['keys'])) {
|
||||
$regions = array_filter(
|
||||
Config::getParam('regions', []),
|
||||
@@ -148,7 +148,7 @@ $server
|
||||
|
||||
$server
|
||||
->workerStart(function () use (&$stack, &$failures) {
|
||||
Timer::tick(1000, function () use (&$stack, &$failures) {
|
||||
Timer::tick(20000, function () use (&$stack, &$failures) {
|
||||
$time = DateTime::now();
|
||||
if (empty($stack['keys']) && count($failures) === 0) {
|
||||
Console::info("[{$time}] Stack is empty");
|
||||
@@ -170,8 +170,9 @@ $server
|
||||
array_splice($stack['keys'], 0, CHUNK_MAX_KEYS);
|
||||
Console::info("[{$time}] Sending " . count($chunk) . " remains " . count($stack['keys']));
|
||||
call($stack['regions'], $chunk);
|
||||
//var_dump($stack['keys']);
|
||||
$chunk = [];
|
||||
});
|
||||
echo "Out region [" . App::getEnv('_APP_REGION', 'nyc1') . "] cache purging worker Started" . PHP_EOL;
|
||||
echo "Out [" . App::getEnv('_APP_REGION', 'nyc1') . "] edge cache purging worker Started" . PHP_EOL;
|
||||
})
|
||||
->start();
|
||||
|
||||
Generated
+16
-16
@@ -693,16 +693,16 @@
|
||||
},
|
||||
{
|
||||
"name": "guzzlehttp/psr7",
|
||||
"version": "2.4.2",
|
||||
"version": "2.4.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/guzzle/psr7.git",
|
||||
"reference": "3148458748274be1546f8f2809a6c09fe66f44aa"
|
||||
"reference": "67c26b443f348a51926030c83481b85718457d3d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/guzzle/psr7/zipball/3148458748274be1546f8f2809a6c09fe66f44aa",
|
||||
"reference": "3148458748274be1546f8f2809a6c09fe66f44aa",
|
||||
"url": "https://api.github.com/repos/guzzle/psr7/zipball/67c26b443f348a51926030c83481b85718457d3d",
|
||||
"reference": "67c26b443f348a51926030c83481b85718457d3d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -792,7 +792,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/guzzle/psr7/issues",
|
||||
"source": "https://github.com/guzzle/psr7/tree/2.4.2"
|
||||
"source": "https://github.com/guzzle/psr7/tree/2.4.3"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -808,7 +808,7 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2022-10-25T13:49:28+00:00"
|
||||
"time": "2022-10-26T14:07:24+00:00"
|
||||
},
|
||||
{
|
||||
"name": "influxdb/influxdb-php",
|
||||
@@ -1901,12 +1901,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/cache.git",
|
||||
"reference": "d0cd43b679fa23dc720c3bb9dff4c47c0eb4790d"
|
||||
"reference": "c29179055def7827b27fde979cefe07c3e4858da"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/cache/zipball/d0cd43b679fa23dc720c3bb9dff4c47c0eb4790d",
|
||||
"reference": "d0cd43b679fa23dc720c3bb9dff4c47c0eb4790d",
|
||||
"url": "https://api.github.com/repos/utopia-php/cache/zipball/c29179055def7827b27fde979cefe07c3e4858da",
|
||||
"reference": "c29179055def7827b27fde979cefe07c3e4858da",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -1942,7 +1942,7 @@
|
||||
"issues": "https://github.com/utopia-php/cache/issues",
|
||||
"source": "https://github.com/utopia-php/cache/tree/feat-redis-sync"
|
||||
},
|
||||
"time": "2022-10-26T08:25:43+00:00"
|
||||
"time": "2022-10-27T14:35:59+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/cli",
|
||||
@@ -3635,16 +3635,16 @@
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-code-coverage",
|
||||
"version": "9.2.17",
|
||||
"version": "9.2.18",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
|
||||
"reference": "aa94dc41e8661fe90c7316849907cba3007b10d8"
|
||||
"reference": "12fddc491826940cf9b7e88ad9664cf51f0f6d0a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/aa94dc41e8661fe90c7316849907cba3007b10d8",
|
||||
"reference": "aa94dc41e8661fe90c7316849907cba3007b10d8",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/12fddc491826940cf9b7e88ad9664cf51f0f6d0a",
|
||||
"reference": "12fddc491826940cf9b7e88ad9664cf51f0f6d0a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -3700,7 +3700,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
|
||||
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.17"
|
||||
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.18"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -3708,7 +3708,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2022-08-30T12:24:04+00:00"
|
||||
"time": "2022-10-27T13:35:33+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-file-iterator",
|
||||
|
||||
@@ -108,6 +108,8 @@ services:
|
||||
- ./public:/usr/src/code/public
|
||||
- ./src:/usr/src/code/src
|
||||
- ./dev:/usr/local/dev
|
||||
- ./vendor/utopia-php/cache:/usr/src/code/vendor/utopia-php/cache
|
||||
- ./vendor/utopia-php/database:/usr/src/code/vendor/utopia-php/database
|
||||
depends_on:
|
||||
- mariadb
|
||||
- redis
|
||||
@@ -279,6 +281,8 @@ services:
|
||||
- ./app:/usr/src/code/app
|
||||
- ./src:/usr/src/code/src
|
||||
- ./vendor/utopia-php/queue:/usr/src/code/vendor/utopia-php/queue
|
||||
- ./vendor/utopia-php/cache:/usr/src/code/vendor/utopia-php/cache
|
||||
- ./vendor/utopia-php/database:/usr/src/code/vendor/utopia-php/database
|
||||
depends_on:
|
||||
- mariadb
|
||||
- redis
|
||||
@@ -308,6 +312,8 @@ services:
|
||||
volumes:
|
||||
- ./app:/usr/src/code/app
|
||||
- ./src:/usr/src/code/src
|
||||
- ./vendor/utopia-php/cache:/usr/src/code/vendor/utopia-php/cache
|
||||
- ./vendor/utopia-php/database:/usr/src/code/vendor/utopia-php/database
|
||||
depends_on:
|
||||
- redis
|
||||
environment:
|
||||
|
||||
Reference in New Issue
Block a user