1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-14 11:54:04 +00:00

Add Predis support (#59)

* wip

* Add Predis support

* Enable phpredis extension only for some builds

* Add note about phpredis

* Fix if command

* Revert travis changes & add a version check to predis tests
This commit is contained in:
Samuel Štancl 2019-07-03 14:48:55 +02:00 committed by GitHub
parent e7b5a77a6b
commit 1b6759084f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 75 additions and 18 deletions

View file

@ -5,6 +5,8 @@ namespace Stancl\Tenancy\Traits;
use Stancl\Tenancy\CacheManager;
use Illuminate\Support\Facades\Redis;
use Illuminate\Support\Facades\Storage;
use Symfony\Component\Debug\Exception\FatalThrowableError;
use Stancl\Tenancy\Exceptions\PhpRedisNotInstalledException;
trait BootstrapsTenancy
{
@ -13,7 +15,9 @@ trait BootstrapsTenancy
public function bootstrap()
{
$this->switchDatabaseConnection();
$this->setPhpRedisPrefix($this->app['config']['tenancy.redis.prefixed_connections']);
if ($this->app['config']['tenancy.redis.tenancy']) {
$this->setPhpRedisPrefix($this->app['config']['tenancy.redis.prefixed_connections']);
}
$this->tagCache();
$this->suffixFilesystemRootPaths();
}
@ -28,7 +32,11 @@ trait BootstrapsTenancy
foreach ($connections as $connection) {
$prefix = $this->app['config']['tenancy.redis.prefix_base'] . $this->tenant['uuid'];
$client = Redis::connection($connection)->client();
$client->setOption($client::OPT_PREFIX, $prefix);
try {
$client->setOption($client::OPT_PREFIX, $prefix);
} catch (\Throwable $t) {
throw new PhpRedisNotInstalledException();
}
}
}