5 Commits
1.0.1 ... 1.0.3

Author SHA1 Message Date
Ian Morland
3284a36926 Cleanup 2021-07-05 14:12:08 +01:00
Ian Morland
68af330669 Add optional prefix 2021-07-01 21:28:35 +01:00
Ian Morland
09a30f786d Update usage 2021-07-01 21:26:55 +01:00
Ian Morland
68a5cafdfc Address failure when only running selected redis services 2021-07-01 21:23:57 +01:00
Ian Morland
ed83a0123d Update blomstra/flarum-redis requirement 2021-06-25 09:36:15 +01:00
6 changed files with 599 additions and 596 deletions

View File

@@ -10,15 +10,16 @@ Makes it easy to enable/disable Redis features:
- Queue
- Sessions
For this to work, environment variables have to be set on your host:
If you are using a local redis setup, you will likely be able to simply use the defaults provided. Any of these can be overridden using environment variables as follows:
```ini
REDIS_HOST=null # Required
REDIS_HOST='127.0.0.1 # Optional, else uses default
REDIS_PORT=6379 # Optional, else uses default
REDIS_PASSWORD=null # Required, can be an empty string
REDIS_PASSWORD=null # Optional, otherwise null
REDIS_DATABASE_CACHE=1 # Optional, else uses default
REDIS_DATABASE_QUEUE=2 # Optional, else uses default
REDIS_DATABASE_SESSION=3 # Optional, else uses default
REDIS_PREFIX='flarum_' # Optional, else uses default
```
## 📥 Installation

View File

@@ -14,8 +14,8 @@
},
"homepage": "https://glowingblue.com",
"require": {
"flarum/core": "^1.0.0",
"blomstra/flarum-redis": "^0.4.0@beta"
"flarum/core": "^1.0.4",
"blomstra/flarum-redis": "^0.4.0"
},
"authors": [
{

View File

@@ -12,7 +12,7 @@
namespace GlowingBlue\RedisSetup;
use Flarum\Extend;
use GlowingBlue\RedisSetup\Extend\EnableRedis;
use GlowingBlue\RedisSetup\Extend as GBExtend;
use GlowingBlue\RedisSetup\Provider\QueueProvider;
return [
@@ -21,8 +21,8 @@ return [
new Extend\Locales(__DIR__.'/resources/locale'),
new GBExtend\EnableRedis(),
(new Extend\ServiceProvider())
->register(QueueProvider::class),
new EnableRedis()
];

1144
js/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -3,7 +3,7 @@
"version": "0.0.0",
"private": true,
"dependencies": {
"flarum-webpack-config": "^0.1.0-beta.10",
"flarum-webpack-config": "^1.0.0",
"webpack": "^4.26.0",
"webpack-cli": "^3.0.7"
},

View File

@@ -19,9 +19,9 @@ class EnableRedis implements ExtenderInterface
{
$config = $this->buildConfig();
if (Arr::hasAny($config, [self::CACHE_KEY, self::QUEUE_KEY, self::SESSION_KEY])) {
(new Redis($config))->disable($this->getDisabledServices())->extend($container, $extension);
}
(new Redis($config))
->disable($this->getDisabledServices())
->extend($container, $extension);
}
private function getDisabledServices(): array
@@ -46,19 +46,14 @@ class EnableRedis implements ExtenderInterface
return $disabled;
}
private function buildConfig(): array
private function buildConfig($config = []): array
{
if ($this->getHost() === null) {
return [];
}
$config = [];
$cache = [
'host' => $this->getHost(),
'password' => $this->getPassword(),
'port' => $this->getPort(),
'database' => $this->getCacheDatabase(),
'prefix' => $this->getPrefix(),
];
$queue = [
@@ -66,6 +61,7 @@ class EnableRedis implements ExtenderInterface
'password' => $this->getPassword(),
'port' => $this->getPort(),
'database' => $this->getQueueDatabase(),
'prefix' => $this->getPrefix(),
];
$session = [
@@ -73,6 +69,7 @@ class EnableRedis implements ExtenderInterface
'password' => $this->getPassword(),
'port' => $this->getPort(),
'database' => $this->getSessionDatabase(),
'prefix' => $this->getPrefix(),
];
$config = Arr::add($config, self::CACHE_KEY, $cache);
@@ -82,9 +79,9 @@ class EnableRedis implements ExtenderInterface
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
@@ -111,4 +108,9 @@ class EnableRedis implements ExtenderInterface
{
return (int) getenv('REDIS_DATABASE_SESSION') ? getenv('REDIS_DATABASE_SESSION') : 3;
}
private function getPrefix(): string
{
return getenv('REDIS_PREFIX') ? getenv('REDIS_PREFIX') : 'flarum_';
}
}