-
-
Notifications
You must be signed in to change notification settings - Fork 596
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Redis Support for cache and sessions
- Loading branch information
1 parent
9fd512b
commit 9ac2732
Showing
5 changed files
with
141 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
|
||
namespace Leantime\Core\Providers; | ||
|
||
use Illuminate\Cache\MemcachedConnector; | ||
use Illuminate\Contracts\Redis\Factory; | ||
use Illuminate\Redis\RedisManager; | ||
use Illuminate\Support\Arr; | ||
use Illuminate\Support\ServiceProvider; | ||
use Leantime\Core\AppSettings; | ||
use Leantime\Core\CliRequest; | ||
use Leantime\Core\Events; | ||
use Leantime\Core\IncomingRequest; | ||
use Leantime\Domain\Setting\Services\Setting as SettingsService; | ||
|
||
class Redis extends ServiceProvider | ||
{ | ||
/** | ||
* Register any application services. | ||
* | ||
* @return void | ||
*/ | ||
public function register() | ||
{ | ||
|
||
/** | ||
* @todo the following should eventually automatically turn caches into redis if available, | ||
* then memcached if available, | ||
* then fileStore | ||
*/ | ||
$this->app->singleton(RedisManager::class, function ($app) { | ||
|
||
|
||
app('config')['redis'] = [ | ||
'client' => 'predis', | ||
'options' => [ | ||
'cluster' => app('config')->redisCluster ?? 'redis', | ||
'prefix' => app('config')->redisPrefix ?? 'ltRedis', | ||
], | ||
'default' => [ | ||
'url' => app('config')->redisUrl ?? '', | ||
'host' => app('config')->redisHost ?? '127.0.0.1', | ||
'password' => app('config')->redisPassword ?? null, | ||
'port' => app('config')->redisPort ?? '6379', | ||
'database' => '0', | ||
'prefix' => 'c:' | ||
], | ||
'session' => [ | ||
'url' => app('config')->redisUrl ?? '', | ||
'host' => app('config')->redisHost ?? '127.0.0.1', | ||
'password' => app('config')->redisPassword ?? null, | ||
'port' => app('config')->redisPort ?? '6379', | ||
'database' => '0', | ||
'prefix' => 's:' | ||
], | ||
]; | ||
|
||
$redisManager = new RedisManager(app(), 'predis', app('config')['redis']); | ||
return $redisManager; | ||
|
||
}); | ||
|
||
$this->app->alias(RedisManager::class, 'redis'); | ||
$this->app->alias(RedisManager::class, Factory::class); | ||
$this->app->bind('redis.connection', function ($app) { | ||
return $app['redis']->connection(); | ||
}); | ||
|
||
} | ||
|
||
public function boot() { | ||
|
||
|
||
} | ||
|
||
/** | ||
* Manages the instance cache. | ||
* | ||
* @return void | ||
*/ | ||
public function checkCacheVersion(): void | ||
{ | ||
|
||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters