From 6cf46be7880a54eb7b177e25dd2927c475dc9bf2 Mon Sep 17 00:00:00 2001 From: ghost Date: Sat, 27 Jan 2024 14:31:00 +0200 Subject: [PATCH] init memory in controller --- src/controller/room.php | 11 ++++++++--- src/server.php | 13 ------------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/controller/room.php b/src/controller/room.php index 722d938..a11896b 100644 --- a/src/controller/room.php +++ b/src/controller/room.php @@ -5,16 +5,21 @@ namespace Kevachat\Geminiapp\Controller; class Room { private $_config; - private $_memory; private $_session; private \Kevachat\Kevacoin\Client $_kevacoin; + private \Yggverse\Cache\Memory $_memory; - public function __construct(\Yggverse\Cache\Memory $memory, $config) + public function __construct($config) { // Init memory - $this->_memory = $memory; + $this->_memory = new \Yggverse\Cache\Memory( + $config->memcached->server->host, + $config->memcached->server->port, + $config->memcached->server->namespace, + $config->memcached->server->timeout + ); // Init session $this->_session = rand(); diff --git a/src/server.php b/src/server.php index 51b9a2a..420f4f1 100644 --- a/src/server.php +++ b/src/server.php @@ -49,14 +49,6 @@ $config = json_decode( ) ); -// Init memory -$memory = new \Yggverse\Cache\Memory( - $config->memcached->server->host, - $config->memcached->server->port, - $config->memcached->server->namespace, - $config->memcached->server->timeout -); - // Init server $server = new \Yggverse\TitanII\Server(); @@ -71,7 +63,6 @@ $server->setKey( $server->setHandler( function (\Yggverse\TitanII\Request $request): \Yggverse\TitanII\Response { - global $memory; global $config; $response = new \Yggverse\TitanII\Response(); @@ -95,7 +86,6 @@ $server->setHandler( include_once __DIR__ . '/controller/room.php'; $room = new \Kevachat\Geminiapp\Controller\Room( - $memory, $config ); @@ -123,7 +113,6 @@ $server->setHandler( include_once __DIR__ . '/controller/room.php'; $room = new \Kevachat\Geminiapp\Controller\Room( - $memory, $config ); @@ -189,7 +178,6 @@ $server->setHandler( include_once __DIR__ . '/controller/room.php'; $room = new \Kevachat\Geminiapp\Controller\Room( - $memory, $config ); @@ -234,7 +222,6 @@ $server->setHandler( include_once __DIR__ . '/controller/room.php'; $room = new \Kevachat\Geminiapp\Controller\Room( - $memory, $config );