1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 03:54:04 +00:00

Allow suffix for prefixed Redis connections

This will allow suffixing Redis tenant connections with a configured suffix or default to `_` for better readability.
This commit is contained in:
Angelos Michalopoulos 2024-01-30 17:44:52 +02:00 committed by GitHub
parent 8db27a358e
commit d198baf55c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -26,10 +26,11 @@ class RedisTenancyBootstrapper implements TenancyBootstrapper
{ {
foreach ($this->prefixedConnections() as $connection) { foreach ($this->prefixedConnections() as $connection) {
$prefix = $this->config['tenancy.redis.prefix_base'] . $tenant->getTenantKey(); $prefix = $this->config['tenancy.redis.prefix_base'] . $tenant->getTenantKey();
$suffix = $this->config['tenancy.redis.suffix'] ?? '_';
$client = Redis::connection($connection)->client(); $client = Redis::connection($connection)->client();
$this->originalPrefixes[$connection] = $client->getOption($client::OPT_PREFIX); $this->originalPrefixes[$connection] = $client->getOption($client::OPT_PREFIX);
$client->setOption($client::OPT_PREFIX, $prefix); $client->setOption($client::OPT_PREFIX, $prefix.$suffix);
} }
} }