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

Add note about phpredis

This commit is contained in:
Samuel Štancl 2019-07-03 13:23:02 +02:00
parent 03ee52e62a
commit 998f065338
5 changed files with 8 additions and 5 deletions

View file

@ -20,7 +20,6 @@ You won't have to change a thing in your application's code.\*
### Requirements ### Requirements
- Laravel 5.7 or 5.8 - Laravel 5.7 or 5.8
- phpredis (predis is not supported)
### Installing the package ### Installing the package
@ -97,6 +96,8 @@ config('tenancy.redis.prefix_base') . $uuid
These changes will only apply for connections listed in `prefixed_connections`. These changes will only apply for connections listed in `prefixed_connections`.
> **Note: *If you want Redis to be multi-tenant, you <u>must</u> use phpredis. Predis does not support prefixes.***
#### `cache` #### `cache`
Cache keys will be tagged with a tag: 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. 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 ## Cache

View file

@ -15,7 +15,7 @@ trait BootstrapsTenancy
public function bootstrap() public function bootstrap()
{ {
$this->switchDatabaseConnection(); $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->setPhpRedisPrefix($this->app['config']['tenancy.redis.prefixed_connections']);
} }
$this->tagCache(); $this->tagCache();

View file

@ -12,7 +12,7 @@ return [
'suffix' => '', 'suffix' => '',
], ],
'redis' => [ 'redis' => [
'multitenant' => true, 'tenancy' => false,
'prefix_base' => 'tenant', 'prefix_base' => 'tenant',
'prefixed_connections' => [ 'prefixed_connections' => [
'default', 'default',

View file

@ -37,7 +37,7 @@ class BootstrapsTenancyTest extends TestCase
{ {
Config::set('database.redis.client', 'predis'); Config::set('database.redis.client', 'predis');
Redis::setDriver('predis'); Redis::setDriver('predis');
Config::set('tenancy.redis.multitenant', false); Config::set('tenancy.redis.tenancy', false);
// assert no exception is thrown from initializing tenancy // assert no exception is thrown from initializing tenancy
$this->assertNotNull($this->initTenancy()); $this->assertNotNull($this->initTenancy());
@ -48,6 +48,7 @@ class BootstrapsTenancyTest extends TestCase
{ {
Config::set('database.redis.client', 'predis'); Config::set('database.redis.client', 'predis');
Redis::setDriver('predis'); Redis::setDriver('predis');
Config::set('tenancy.redis.tenancy', true);
$this->expectException(PhpRedisNotInstalledException::class); $this->expectException(PhpRedisNotInstalledException::class);
$this->initTenancy(); $this->initTenancy();

View file

@ -72,6 +72,7 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
'public', 'public',
's3', 's3',
], ],
'tenancy.redis.tenancy' => true,
]); ]);
} }