mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 16:44:04 +00:00
Update DatabaseCacheBootstrapper to also handle cache locks connection
This commit is contained in:
parent
3238592364
commit
6c3324ef86
1 changed files with 5 additions and 0 deletions
|
|
@ -26,13 +26,17 @@ class DatabaseCacheBootstrapper implements TenancyBootstrapper
|
||||||
protected Repository $config,
|
protected Repository $config,
|
||||||
protected CacheManager $cache,
|
protected CacheManager $cache,
|
||||||
protected string|null $originalConnection = null,
|
protected string|null $originalConnection = null,
|
||||||
|
protected string|null $originalLockConnection = null
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public function bootstrap(Tenant $tenant): void
|
public function bootstrap(Tenant $tenant): void
|
||||||
{
|
{
|
||||||
$this->originalConnection = $this->config->get('cache.stores.database.connection');
|
$this->originalConnection = $this->config->get('cache.stores.database.connection');
|
||||||
|
$this->originalLockConnection = $this->config->get('cache.stores.database.lock_connection');
|
||||||
|
|
||||||
|
// todo1 Maybe consider making this dynamic instead of hardcoding 'tenant'?
|
||||||
$this->config->set('cache.stores.database.connection', 'tenant');
|
$this->config->set('cache.stores.database.connection', 'tenant');
|
||||||
|
$this->config->set('cache.stores.database.lock_connection', 'tenant');
|
||||||
|
|
||||||
$this->cache->purge('database');
|
$this->cache->purge('database');
|
||||||
}
|
}
|
||||||
|
|
@ -40,6 +44,7 @@ class DatabaseCacheBootstrapper implements TenancyBootstrapper
|
||||||
public function revert(): void
|
public function revert(): void
|
||||||
{
|
{
|
||||||
$this->config->set('cache.stores.database.connection', $this->originalConnection);
|
$this->config->set('cache.stores.database.connection', $this->originalConnection);
|
||||||
|
$this->config->set('cache.stores.database.lock_connection', $this->originalLockConnection);
|
||||||
|
|
||||||
$this->cache->purge('database');
|
$this->cache->purge('database');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue