mirror of
https://github.com/stancl/tenancy-docs.git
synced 2025-12-12 18:24:03 +00:00
3.x redesign
This commit is contained in:
parent
857122540f
commit
f8f354c323
229 changed files with 201175 additions and 22440 deletions
34
source/docs/v3/cached-lookup.blade.md
Normal file
34
source/docs/v3/cached-lookup.blade.md
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
---
|
||||
title: Cached tenant lookup
|
||||
extends: _layouts.documentation
|
||||
section: content
|
||||
---
|
||||
|
||||
|
||||
# Cached lookup
|
||||
|
||||
If you're using multiple databases, you may want to avoid making a query to the central database on **each tenant request** — for tenant identification. Even though the queries are very simple, the app has to establish a connection with the central database which is expensive.
|
||||
|
||||
To avoid this, you may enable caching on the tenant resolvers (all in the `Stancl\Tenancy\Resolvers` namespace):
|
||||
|
||||
- `DomainTenantResolver` (also used for subdomain identification)
|
||||
- `PathTenantResolver`
|
||||
- `RequestDataTenantResolver`
|
||||
|
||||
On each of these classes, you may set the following static properties:
|
||||
|
||||
```php
|
||||
// TenancyServiceProvider::boot()
|
||||
|
||||
use Stancl\Tenancy\Resolvers;
|
||||
|
||||
// enable cache
|
||||
DomainTenantResolver::$shouldCache = true;
|
||||
|
||||
// seconds, 3600 is the default value
|
||||
DomainTenantResolver::$cacheTTL = 3600;
|
||||
|
||||
// specify some cache store
|
||||
// null resolves to the default cache store
|
||||
DomainTenantResolver::$cacheStore = 'redis';
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue