mirror of
https://github.com/grocy/grocy.git
synced 2026-04-06 21:06:15 +02:00
try storing app in apcu
This commit is contained in:
parent
75a3c6c62e
commit
06e210a0b9
54
app.php
54
app.php
|
|
@ -49,30 +49,36 @@ if (GROCY_DISABLE_AUTH === true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup base application
|
if (!apcu_exists("grocy_app"))
|
||||||
$appContainer = new \Slim\Container([
|
{
|
||||||
'settings' => [
|
|
||||||
'displayErrorDetails' => true,
|
// Setup base application
|
||||||
'determineRouteBeforeAppMiddleware' => true
|
$appContainer = new \Slim\Container([
|
||||||
],
|
'settings' => [
|
||||||
'view' => function($container)
|
'displayErrorDetails' => true,
|
||||||
{
|
'determineRouteBeforeAppMiddleware' => true
|
||||||
return new \Slim\Views\Blade(__DIR__ . '/views', GROCY_DATAPATH . '/viewcache');
|
],
|
||||||
},
|
'view' => function($container)
|
||||||
'LoginControllerInstance' => function($container)
|
{
|
||||||
{
|
return new \Slim\Views\Blade(__DIR__ . '/views', GROCY_DATAPATH . '/viewcache');
|
||||||
return new LoginController($container, 'grocy_session');
|
},
|
||||||
},
|
'LoginControllerInstance' => function($container)
|
||||||
'UrlManager' => function($container)
|
{
|
||||||
{
|
return new LoginController($container, 'grocy_session');
|
||||||
return new UrlManager(GROCY_BASE_URL);
|
},
|
||||||
},
|
'UrlManager' => function($container)
|
||||||
'ApiKeyHeaderName' => function($container)
|
{
|
||||||
{
|
return new UrlManager(GROCY_BASE_URL);
|
||||||
return 'GROCY-API-KEY';
|
},
|
||||||
}
|
'ApiKeyHeaderName' => function($container)
|
||||||
]);
|
{
|
||||||
$app = new \Slim\App($appContainer);
|
return 'GROCY-API-KEY';
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
apcu_store("grocy_app", new \Slim\App($appContainer));
|
||||||
|
}
|
||||||
|
|
||||||
|
$app = apcu_fetch("grocy_app");
|
||||||
|
|
||||||
#$fp = fopen('/www/data/sql.log', 'a');
|
#$fp = fopen('/www/data/sql.log', 'a');
|
||||||
#fwrite($fp, "!!!Starting up loading app\n");
|
#fwrite($fp, "!!!Starting up loading app\n");
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ class LoginController extends BaseController
|
||||||
public function __construct(\Slim\Container $container, string $sessionCookieName)
|
public function __construct(\Slim\Container $container, string $sessionCookieName)
|
||||||
{
|
{
|
||||||
parent::__construct($container);
|
parent::__construct($container);
|
||||||
$this->SessionService = new SessionService();
|
$this->SessionService = SessionService::getInstance();
|
||||||
$this->SessionCookieName = $sessionCookieName;
|
$this->SessionCookieName = $sessionCookieName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ class ApiKeyAuthMiddleware extends BaseMiddleware
|
||||||
$validApiKey = true;
|
$validApiKey = true;
|
||||||
$usedApiKey = null;
|
$usedApiKey = null;
|
||||||
|
|
||||||
$sessionService = new SessionService();
|
$sessionService = SessionService::getInstance();
|
||||||
if (!isset($_COOKIE[$this->SessionCookieName]) || !$sessionService->IsValidSession($_COOKIE[$this->SessionCookieName]))
|
if (!isset($_COOKIE[$this->SessionCookieName]) || !$sessionService->IsValidSession($_COOKIE[$this->SessionCookieName]))
|
||||||
{
|
{
|
||||||
$validSession = false;
|
$validSession = false;
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ class SessionAuthMiddleware extends BaseMiddleware
|
||||||
{
|
{
|
||||||
$route = $request->getAttribute('route');
|
$route = $request->getAttribute('route');
|
||||||
$routeName = $route->getName();
|
$routeName = $route->getName();
|
||||||
$sessionService = new SessionService();
|
$sessionService = SessionService::getInstance();
|
||||||
|
|
||||||
if ($routeName === 'root')
|
if ($routeName === 'root')
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,18 @@ namespace Grocy\Services;
|
||||||
|
|
||||||
class SessionService extends BaseService
|
class SessionService extends BaseService
|
||||||
{
|
{
|
||||||
|
private static $instance = null;
|
||||||
|
|
||||||
|
public function getInstance()
|
||||||
|
{
|
||||||
|
if (self::$instance == null)
|
||||||
|
{
|
||||||
|
self::$instance = new self();
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::$instance;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user