mirror of
https://github.com/glowingblue/flarum-ext-redis-setup.git
synced 2026-03-22 06:57:45 +01:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
77ad7422e7 | ||
|
|
4f261dbee4 | ||
|
|
d59ebfa684 | ||
|
|
b03ca35d54 |
2
.github/workflows/backend.yml
vendored
2
.github/workflows/backend.yml
vendored
@@ -8,6 +8,6 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
enable_backend_testing: false
|
enable_backend_testing: false
|
||||||
enable_phpstan: true
|
enable_phpstan: true
|
||||||
php_versions: '["7.4", "8.0", "8.1", "8.2", "8.3", "8.4"]'
|
php_versions: '["8.1", "8.2", "8.3", "8.4"]'
|
||||||
|
|
||||||
backend_directory: .
|
backend_directory: .
|
||||||
|
|||||||
6
.github/workflows/frontend.yml
vendored
6
.github/workflows/frontend.yml
vendored
@@ -13,7 +13,11 @@ jobs:
|
|||||||
frontend_directory: ./js
|
frontend_directory: ./js
|
||||||
backend_directory: .
|
backend_directory: .
|
||||||
js_package_manager: yarn
|
js_package_manager: yarn
|
||||||
main_git_branch: master
|
main_git_branch: 1.x
|
||||||
|
|
||||||
|
git_actor_name: ${{ vars.GIT_ACTOR_NAME }}
|
||||||
|
git_actor_email: ${{ vars.GIT_ACTOR_EMAIL }}
|
||||||
|
|
||||||
secrets:
|
secrets:
|
||||||
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}
|
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}
|
||||||
|
git_actor_token: ${{ secrets.GIT_ACTOR_TOKEN }}
|
||||||
|
|||||||
@@ -38,6 +38,14 @@ composer update glowingblue/redis-setup
|
|||||||
php flarum cache:clear
|
php flarum cache:clear
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Compatibility with `fof/redis`
|
||||||
|
|
||||||
|
This extension depends on [`fof/redis`](https://github.com/FriendsOfFlarum/redis) and deliberately disables the **`settings` service** that `fof/redis` ≥ 1.1 provides.
|
||||||
|
|
||||||
|
`fof/redis`'s settings service replaces Flarum's `SettingsRepositoryInterface` with a Redis-backed caching layer. However, this extension reads settings (e.g. which Redis services to enable) during its own boot sequence — *before* Redis is fully wired into the container. Enabling the Redis settings cache here would create a circular dependency: configuring Redis requires reading settings, but reading settings requires Redis.
|
||||||
|
|
||||||
|
The `settings` service from `fof/redis` is therefore always disabled in this extension's extender. If you want Redis-backed settings caching, configure `fof/redis` directly in your project's root `extend.php` instead of using this extension.
|
||||||
|
|
||||||
## 🔗 Links
|
## 🔗 Links
|
||||||
|
|
||||||
- [Flarum Discuss post](https://discuss.flarum.org/d/27455)
|
- [Flarum Discuss post](https://discuss.flarum.org/d/27455)
|
||||||
|
|||||||
@@ -18,8 +18,9 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://glowingblue.com",
|
"homepage": "https://glowingblue.com",
|
||||||
"require": {
|
"require": {
|
||||||
|
"php": "^8.1",
|
||||||
"flarum/core": "^1.8.5",
|
"flarum/core": "^1.8.5",
|
||||||
"fof/redis": "^1.0"
|
"fof/redis": "^1.1.4"
|
||||||
},
|
},
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,4 +6,4 @@ glowingblue-redis-setup:
|
|||||||
Enable Redis sessions (all users will be logged out after changing this setting)
|
Enable Redis sessions (all users will be logged out after changing this setting)
|
||||||
enable_queue: Enable Redis queue
|
enable_queue: Enable Redis queue
|
||||||
horizon_config: "Horizon config (format: JSON)."
|
horizon_config: "Horizon config (format: JSON)."
|
||||||
horizon_help_text: This will be passed to <code>(new \Blomstra\Horizon\Extend\Horizon)->config(...))</code>
|
horizon_help_text: This will be passed to <code>(new \FoF\Horizon\Extend\Horizon)->config(...))</code>
|
||||||
|
|||||||
@@ -29,8 +29,11 @@ class EnableRedis implements ExtenderInterface
|
|||||||
{
|
{
|
||||||
$config = $this->buildConfig();
|
$config = $this->buildConfig();
|
||||||
|
|
||||||
(new Redis($config))
|
/** @var Redis $redis */
|
||||||
->disable($this->getDisabledServices());
|
$redis = (new Redis($config))
|
||||||
|
->disable(['settings', ...$this->getDisabledServices()]);
|
||||||
|
|
||||||
|
$redis->extend($container, $extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getDisabledServices(): array
|
private function getDisabledServices(): array
|
||||||
@@ -85,36 +88,42 @@ class EnableRedis implements ExtenderInterface
|
|||||||
|
|
||||||
public static function getHost(): string
|
public static function getHost(): string
|
||||||
{
|
{
|
||||||
return getenv('REDIS_HOST') ? getenv('REDIS_HOST') : '127.0.0.1';
|
return getenv('REDIS_HOST') ?: '127.0.0.1';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getPassword(): ?string
|
public static function getPassword(): ?string
|
||||||
{
|
{
|
||||||
return getenv('REDIS_PASSWORD') ? getenv('REDIS_PASSWORD') : null;
|
return getenv('REDIS_PASSWORD') ?: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getPort(): string
|
public static function getPort(): string
|
||||||
{
|
{
|
||||||
return getenv('REDIS_PORT') ? getenv('REDIS_PORT') : '6379';
|
return getenv('REDIS_PORT') ?: '6379';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getCacheDatabase(): int
|
public static function getCacheDatabase(): int
|
||||||
{
|
{
|
||||||
return (int) getenv('REDIS_DATABASE_CACHE') ? getenv('REDIS_DATABASE_CACHE') : 1;
|
$val = getenv('REDIS_DATABASE_CACHE');
|
||||||
|
|
||||||
|
return $val !== false ? (int) $val : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getQueueDatabase(): int
|
public static function getQueueDatabase(): int
|
||||||
{
|
{
|
||||||
return (int) getenv('REDIS_DATABASE_QUEUE') ? getenv('REDIS_DATABASE_QUEUE') : 2;
|
$val = getenv('REDIS_DATABASE_QUEUE');
|
||||||
|
|
||||||
|
return $val !== false ? (int) $val : 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getSessionDatabase(): int
|
public static function getSessionDatabase(): int
|
||||||
{
|
{
|
||||||
return (int) getenv('REDIS_DATABASE_SESSION') ? getenv('REDIS_DATABASE_SESSION') : 3;
|
$val = getenv('REDIS_DATABASE_SESSION');
|
||||||
|
|
||||||
|
return $val !== false ? (int) $val : 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getPrefix(): string
|
public static function getPrefix(): string
|
||||||
{
|
{
|
||||||
return getenv('REDIS_PREFIX') ? getenv('REDIS_PREFIX') : 'flarum_';
|
return getenv('REDIS_PREFIX') ?: 'flarum_';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user