Browse Source

init memory in controller

main
ghost 9 months ago
parent
commit
6cf46be788
  1. 11
      src/controller/room.php
  2. 13
      src/server.php

11
src/controller/room.php

@ -5,16 +5,21 @@ namespace Kevachat\Geminiapp\Controller;
class Room class Room
{ {
private $_config; private $_config;
private $_memory;
private $_session; private $_session;
private \Kevachat\Kevacoin\Client $_kevacoin; private \Kevachat\Kevacoin\Client $_kevacoin;
private \Yggverse\Cache\Memory $_memory;
public function __construct(\Yggverse\Cache\Memory $memory, $config) public function __construct($config)
{ {
// Init memory // 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 // Init session
$this->_session = rand(); $this->_session = rand();

13
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 // Init server
$server = new \Yggverse\TitanII\Server(); $server = new \Yggverse\TitanII\Server();
@ -71,7 +63,6 @@ $server->setKey(
$server->setHandler( $server->setHandler(
function (\Yggverse\TitanII\Request $request): \Yggverse\TitanII\Response function (\Yggverse\TitanII\Request $request): \Yggverse\TitanII\Response
{ {
global $memory;
global $config; global $config;
$response = new \Yggverse\TitanII\Response(); $response = new \Yggverse\TitanII\Response();
@ -95,7 +86,6 @@ $server->setHandler(
include_once __DIR__ . '/controller/room.php'; include_once __DIR__ . '/controller/room.php';
$room = new \Kevachat\Geminiapp\Controller\Room( $room = new \Kevachat\Geminiapp\Controller\Room(
$memory,
$config $config
); );
@ -123,7 +113,6 @@ $server->setHandler(
include_once __DIR__ . '/controller/room.php'; include_once __DIR__ . '/controller/room.php';
$room = new \Kevachat\Geminiapp\Controller\Room( $room = new \Kevachat\Geminiapp\Controller\Room(
$memory,
$config $config
); );
@ -189,7 +178,6 @@ $server->setHandler(
include_once __DIR__ . '/controller/room.php'; include_once __DIR__ . '/controller/room.php';
$room = new \Kevachat\Geminiapp\Controller\Room( $room = new \Kevachat\Geminiapp\Controller\Room(
$memory,
$config $config
); );
@ -234,7 +222,6 @@ $server->setHandler(
include_once __DIR__ . '/controller/room.php'; include_once __DIR__ . '/controller/room.php';
$room = new \Kevachat\Geminiapp\Controller\Room( $room = new \Kevachat\Geminiapp\Controller\Room(
$memory,
$config $config
); );

Loading…
Cancel
Save