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

Add a section on creating a Redis connection for tenancy data

This commit is contained in:
Samuel Štancl 2019-01-19 11:38:35 +01:00 committed by GitHub
parent deb3ad77f5
commit 893f664934
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -131,6 +131,25 @@ You can see an example in the [Filesystem](#Filesystem) section of the documenta
# Usage
## Creating a Redis connection for storing tenancy-related data
Add an array like this to `database.redis` config:
```
'tenancy' => [
'host' => env('REDIS_TENANCY_HOST', '127.0.0.1'),
'password' => env('REDIS_TENANCY_PASSWORD', null),
'port' => env('REDIS_TENANCY_PORT', 6380),
'database' => env('REDIS_TENANCY_DB', 3),
],
```
Note the different `database` number and the different port.
A different port is used in this example, because if you use Redis for caching, you may want to run one instance with no persistence and another instance with persistence for tenancy-related data. If you want to run only one Redis instance, just make sure you use a different database number to avoid collisions.
Read the [Storage driver](#storage-driver) section for more information.
## Obtaining a `TenantManager` instance
You can use the `tenancy()` and `tenant()` helpers to resolve `Stancl\Tenancy\TenantManager` out of the service container. These two helpers are exactly the same, the only reason there are two is nice syntax. `tenancy()->init()` sounds better than `tenant()->init()` and `tenant()->create()` sounds better than `tenancy()->create()`.