diff --git a/README.md b/README.md index 40f2cede..de7c51b1 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,6 @@ You won't have to change a thing in your application's code.\* ### Requirements - Laravel 5.7 or 5.8 -- phpredis (predis is not supported) ### Installing the package @@ -97,6 +96,8 @@ config('tenancy.redis.prefix_base') . $uuid These changes will only apply for connections listed in `prefixed_connections`. +> **Note: *If you want Redis to be multi-tenant, you must use phpredis. Predis does not support prefixes.*** + #### `cache` Cache keys will be tagged with a tag: @@ -326,7 +327,7 @@ The entire application will use a new database connection. The connection will b Connections listed in the `tenancy.redis.prefixed_connections` config array use a prefix based on the `tenancy.redis.prefix_base` and the tenant UUID. -**Note: You *must* use phpredis. Predis doesn't support prefixes.** +**Note: You *must* use phpredis if you want mutli-tenant Redis. Predis doesn't support prefixes.** ## Cache diff --git a/src/Traits/BootstrapsTenancy.php b/src/Traits/BootstrapsTenancy.php index 4d2c50f5..f8441b66 100644 --- a/src/Traits/BootstrapsTenancy.php +++ b/src/Traits/BootstrapsTenancy.php @@ -15,7 +15,7 @@ trait BootstrapsTenancy public function bootstrap() { $this->switchDatabaseConnection(); - if ($this->app['config']['tenancy.redis.multitenant']) { + if ($this->app['config']['tenancy.redis.tenancy']) { $this->setPhpRedisPrefix($this->app['config']['tenancy.redis.prefixed_connections']); } $this->tagCache(); diff --git a/src/config/tenancy.php b/src/config/tenancy.php index c85dbabc..c414a688 100644 --- a/src/config/tenancy.php +++ b/src/config/tenancy.php @@ -12,7 +12,7 @@ return [ 'suffix' => '', ], 'redis' => [ - 'multitenant' => true, + 'tenancy' => false, 'prefix_base' => 'tenant', 'prefixed_connections' => [ 'default', diff --git a/tests/BootstrapsTenancyTest.php b/tests/BootstrapsTenancyTest.php index e2c8b1ba..c6c22d2a 100644 --- a/tests/BootstrapsTenancyTest.php +++ b/tests/BootstrapsTenancyTest.php @@ -37,7 +37,7 @@ class BootstrapsTenancyTest extends TestCase { Config::set('database.redis.client', 'predis'); Redis::setDriver('predis'); - Config::set('tenancy.redis.multitenant', false); + Config::set('tenancy.redis.tenancy', false); // assert no exception is thrown from initializing tenancy $this->assertNotNull($this->initTenancy()); @@ -48,6 +48,7 @@ class BootstrapsTenancyTest extends TestCase { Config::set('database.redis.client', 'predis'); Redis::setDriver('predis'); + Config::set('tenancy.redis.tenancy', true); $this->expectException(PhpRedisNotInstalledException::class); $this->initTenancy(); diff --git a/tests/TestCase.php b/tests/TestCase.php index 1cc19ad1..29e0ba7a 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -72,6 +72,7 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase 'public', 's3', ], + 'tenancy.redis.tenancy' => true, ]); }