From d198baf55c1cbcb5532dd056fa7eb947af6bc6ac Mon Sep 17 00:00:00 2001 From: Angelos Michalopoulos Date: Tue, 30 Jan 2024 17:44:52 +0200 Subject: [PATCH] Allow suffix for prefixed Redis connections This will allow suffixing Redis tenant connections with a configured suffix or default to `_` for better readability. --- src/Bootstrappers/RedisTenancyBootstrapper.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Bootstrappers/RedisTenancyBootstrapper.php b/src/Bootstrappers/RedisTenancyBootstrapper.php index 7536984e..05bb3b27 100644 --- a/src/Bootstrappers/RedisTenancyBootstrapper.php +++ b/src/Bootstrappers/RedisTenancyBootstrapper.php @@ -26,10 +26,11 @@ class RedisTenancyBootstrapper implements TenancyBootstrapper { foreach ($this->prefixedConnections() as $connection) { $prefix = $this->config['tenancy.redis.prefix_base'] . $tenant->getTenantKey(); + $suffix = $this->config['tenancy.redis.suffix'] ?? '_'; $client = Redis::connection($connection)->client(); $this->originalPrefixes[$connection] = $client->getOption($client::OPT_PREFIX); - $client->setOption($client::OPT_PREFIX, $prefix); + $client->setOption($client::OPT_PREFIX, $prefix.$suffix); } }