Skip to content

Commit

Permalink
Add redis
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelfolaron committed Jun 5, 2024
1 parent b987602 commit 1dcf5b1
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 24 deletions.
1 change: 1 addition & 0 deletions .idea/leantime-oss.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/phpspec.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 0 additions & 18 deletions app/Core/AppSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,6 @@ public function loadSettings(Environment $config = null): void
ini_set('display_errors', 0);
}

/*
if (session_status() !== PHP_SESSION_ACTIVE) {
if (filter_var($config->useRedis, FILTER_VALIDATE_BOOL) && (!defined("LEAN_CLI") || !LEAN_CLI)) {
ini_set('session.save_handler', 'redis');
ini_set('session.save_path', $config->redisUrl);
}
//ini_set('session.use_cookies', 1);
ini_set('session.use_only_cookies', 1);
ini_set('session.cookie_httponly', 1);
ini_set('session.use_trans_sid', 0);
}
ini_set('session.cache_limiter', '');
}*/

ini_set("log_errors", 1);

if ($config->logPath != '' && $config->logPath != 'null') {
Expand Down
11 changes: 7 additions & 4 deletions app/Core/Bootloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Illuminate\Contracts\Container\Container as IlluminateContainerContract;
use Illuminate\Contracts\Encryption\Encrypter;
use Illuminate\Contracts\Http\Kernel as HttpKernelContract;
use Illuminate\Redis\RedisManager;
use Illuminate\Session\SessionManager;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Crypt;
Expand Down Expand Up @@ -211,9 +212,7 @@ private function registerCoreBindings(): void
$this->app->singleton(OidcService::class, OidcService::class);
$this->app->singleton(ModulemanagerService::class, ModulemanagerService::class);
$this->app->singleton(\Illuminate\Filesystem\Filesystem::class, fn () => new \Illuminate\Filesystem\Filesystem());

$this->app->singleton(\Illuminate\Encryption\Encrypter::class, function ($app) {

$configKey = app()->make(Environment::class)->sessionPassword;

if (strlen($configKey) > 32) {
Expand All @@ -234,7 +233,8 @@ private function registerCoreBindings(): void

$app['config']['session'] = array(
'driver' => "file",
'lifetime' => app()->make(Environment::class)->sessionExpiration,
'connection' => 'default',
'lifetime' => $app['config']->sessionExpiration,
'expire_on_close' => false,
'encrypt' => true,
'files' => APP_ROOT . '/cache/sessions',
Expand All @@ -249,7 +249,6 @@ private function registerCoreBindings(): void
);

$sessionManager = new \Illuminate\Session\SessionManager($app);
$sessionManager->setDefaultDriver("file");

return $sessionManager;
});
Expand All @@ -268,13 +267,15 @@ private function registerCoreBindings(): void
//installation cache is per server
$app['config']['cache.stores.installation'] = [
'driver' => 'file',
'connection' => 'default',
'path' => APP_ROOT . '/cache/installation',
];

//Instance is per company id
$instanceStore = fn () =>
$app['config']['cache.stores.instance'] = [
'driver' => 'file',
'connection' => 'default',
'path' => APP_ROOT . "/cache/" . $app->make(SettingsService::class)->getCompanyId(),
];

Expand Down Expand Up @@ -327,8 +328,10 @@ private function registerCoreAliases(): void
$this->app->alias(\Illuminate\Session\SessionManager::class, 'session');

$this->app->alias(\Illuminate\Encryption\Encrypter::class, "encrypter");

}


private function clearCache(): void
{
$currentVersion = app()->make(AppSettings::class)->appVersion;
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@
"nikic/php-parser": "^4.17",
"nesbot/carbon": "^2.72",
"spatie/icalendar-generator": "^2.6",
"carbon-cli/carbon-cli": "^1.2"
"carbon-cli/carbon-cli": "^1.2",
"illuminate/redis": "^9.52"
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.8",
Expand Down
56 changes: 55 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1dcf5b1

Please sign in to comment.