mirror of
https://github.com/glowingblue/flarum-ext-redis-setup.git
synced 2026-03-22 06:57:45 +01:00
Address failure when only running selected redis services
This commit is contained in:
@@ -14,7 +14,7 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://glowingblue.com",
|
"homepage": "https://glowingblue.com",
|
||||||
"require": {
|
"require": {
|
||||||
"flarum/core": "^1.0.0",
|
"flarum/core": "^1.0.4",
|
||||||
"blomstra/flarum-redis": "^0.4.0"
|
"blomstra/flarum-redis": "^0.4.0"
|
||||||
},
|
},
|
||||||
"authors": [
|
"authors": [
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ return [
|
|||||||
|
|
||||||
new Extend\Locales(__DIR__.'/resources/locale'),
|
new Extend\Locales(__DIR__.'/resources/locale'),
|
||||||
|
|
||||||
|
new EnableRedis(),
|
||||||
|
|
||||||
(new Extend\ServiceProvider())
|
(new Extend\ServiceProvider())
|
||||||
->register(QueueProvider::class),
|
->register(QueueProvider::class),
|
||||||
|
|
||||||
new EnableRedis()
|
|
||||||
];
|
];
|
||||||
|
|||||||
1144
js/package-lock.json
generated
1144
js/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@
|
|||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"flarum-webpack-config": "^0.1.0-beta.10",
|
"flarum-webpack-config": "^1.0.0",
|
||||||
"webpack": "^4.26.0",
|
"webpack": "^4.26.0",
|
||||||
"webpack-cli": "^3.0.7"
|
"webpack-cli": "^3.0.7"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -18,10 +18,15 @@ class EnableRedis implements ExtenderInterface
|
|||||||
public function extend(Container $container, Extension $extension = null)
|
public function extend(Container $container, Extension $extension = null)
|
||||||
{
|
{
|
||||||
$config = $this->buildConfig();
|
$config = $this->buildConfig();
|
||||||
|
$disabled = $this->getDisabledServices();
|
||||||
|
|
||||||
if (Arr::hasAny($config, [self::CACHE_KEY, self::QUEUE_KEY, self::SESSION_KEY])) {
|
$redis = (new Redis($config));
|
||||||
(new Redis($config))->disable($this->getDisabledServices())->extend($container, $extension);
|
|
||||||
|
foreach ($disabled as $service) {
|
||||||
|
$redis->disable($service);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$redis->extend($container, $extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getDisabledServices(): array
|
private function getDisabledServices(): array
|
||||||
@@ -59,6 +64,7 @@ class EnableRedis implements ExtenderInterface
|
|||||||
'password' => $this->getPassword(),
|
'password' => $this->getPassword(),
|
||||||
'port' => $this->getPort(),
|
'port' => $this->getPort(),
|
||||||
'database' => $this->getCacheDatabase(),
|
'database' => $this->getCacheDatabase(),
|
||||||
|
'prefix' => $this->getPrefix(),
|
||||||
];
|
];
|
||||||
|
|
||||||
$queue = [
|
$queue = [
|
||||||
@@ -66,6 +72,7 @@ class EnableRedis implements ExtenderInterface
|
|||||||
'password' => $this->getPassword(),
|
'password' => $this->getPassword(),
|
||||||
'port' => $this->getPort(),
|
'port' => $this->getPort(),
|
||||||
'database' => $this->getQueueDatabase(),
|
'database' => $this->getQueueDatabase(),
|
||||||
|
'prefix' => $this->getPrefix(),
|
||||||
];
|
];
|
||||||
|
|
||||||
$session = [
|
$session = [
|
||||||
@@ -73,6 +80,7 @@ class EnableRedis implements ExtenderInterface
|
|||||||
'password' => $this->getPassword(),
|
'password' => $this->getPassword(),
|
||||||
'port' => $this->getPort(),
|
'port' => $this->getPort(),
|
||||||
'database' => $this->getSessionDatabase(),
|
'database' => $this->getSessionDatabase(),
|
||||||
|
'prefix' => $this->getPrefix(),
|
||||||
];
|
];
|
||||||
|
|
||||||
$config = Arr::add($config, self::CACHE_KEY, $cache);
|
$config = Arr::add($config, self::CACHE_KEY, $cache);
|
||||||
@@ -82,9 +90,9 @@ class EnableRedis implements ExtenderInterface
|
|||||||
return $config;
|
return $config;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getHost(): ?string
|
private function getHost(): string
|
||||||
{
|
{
|
||||||
return getenv('REDIS_HOST') ? getenv('REDIS_HOST') : null;
|
return getenv('REDIS_HOST') ? getenv('REDIS_HOST') : '127.0.0.1';
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getPassword(): ?string
|
private function getPassword(): ?string
|
||||||
@@ -111,4 +119,9 @@ class EnableRedis implements ExtenderInterface
|
|||||||
{
|
{
|
||||||
return (int) getenv('REDIS_DATABASE_SESSION') ? getenv('REDIS_DATABASE_SESSION') : 3;
|
return (int) getenv('REDIS_DATABASE_SESSION') ? getenv('REDIS_DATABASE_SESSION') : 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getPrefix(): string
|
||||||
|
{
|
||||||
|
return getenv('REDIS_PREFIX') ? getenv('REDIS_PREFIX') : 'flarum_';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user