diff --git a/app/http.php b/app/http.php index d00bbc09eb..60a6d9df6a 100644 --- a/app/http.php +++ b/app/http.php @@ -31,6 +31,13 @@ ResqueScheduler::enqueueAt(\time() + 30, 'v1-certificates', 'CertificatesV1', [ 'validateCNAME' => false, ]); +$register->set('cache', function () use ($register) { // Register cache connection + $redis = $register->get('redisPool')->get(); + $redis->setOption(Redis::OPT_READ_TIMEOUT, -1); + + return $redis; +}, true); + Swoole\Runtime::enableCoroutine(SWOOLE_HOOK_ALL); $http = new Server("0.0.0.0", App::getEnv('PORT', 80)); diff --git a/app/init.php b/app/init.php index bad2320d7c..94f934441b 100644 --- a/app/init.php +++ b/app/init.php @@ -165,7 +165,7 @@ $register->set('dbPool', function () { // Register DB connection PDONative::ATTR_ERRMODE => PDONative::ERRMODE_EXCEPTION, ]); - $pool = new PDOPool($config, 4096); // TODO: Investigate pool size + $pool = new PDOPool($config, 16384); // TODO: Investigate pool size return $pool; }); @@ -226,16 +226,17 @@ $register->set('redisPool', function () { ->withReadTimeout(0) ->withRetryInterval(0); - $pool = new RedisPool($config, 4096); // TODO: Investigate pool size + $pool = new RedisPool($config, 16384); // TODO: Investigate pool size return $pool; }); -$register->set('cache', function () use ($register) { // Register cache connection - $redis = $register->get('redisPool')->get(); +$register->set('cache', function () { // Register cache connection + $redis = new Redis(); + $redis->pconnect(App::getEnv('_APP_REDIS_HOST', ''), App::getEnv('_APP_REDIS_PORT', '')); $redis->setOption(Redis::OPT_READ_TIMEOUT, -1); return $redis; -}, true); +}); $register->set('smtp', function () { $mail = new PHPMailer(true); diff --git a/app/realtime.php b/app/realtime.php index 3217219dc5..120117cf39 100644 --- a/app/realtime.php +++ b/app/realtime.php @@ -5,8 +5,7 @@ require_once __DIR__ . '/init.php'; use Appwrite\Network\Validator\Origin; use Appwrite\Realtime\Realtime; use Appwrite\Utopia\Response; -use Swoole\Database\RedisConfig; -use Swoole\Database\RedisPool; +use Swoole\Database\PDOProxy; use Swoole\Process; use Swoole\Http\Request; use Swoole\Http\Response as SwooleResponse; @@ -36,6 +35,13 @@ $register->set('db', function () use ($register) { return $pdo; }, true); +$register->set('cache', function () use ($register) { // Register cache connection + $redis = $register->get('redisPool')->get(); + $redis->setOption(Redis::OPT_READ_TIMEOUT, -1); + + return $redis; +}, true); + $server = new Server('0.0.0.0', 80); $server->set([