diff --git a/src/Bootstrappers/DatabaseCacheBootstrapper.php b/src/Bootstrappers/DatabaseCacheBootstrapper.php index a1183049..c6e48273 100644 --- a/src/Bootstrappers/DatabaseCacheBootstrapper.php +++ b/src/Bootstrappers/DatabaseCacheBootstrapper.php @@ -9,6 +9,17 @@ use Illuminate\Config\Repository; use Stancl\Tenancy\Contracts\TenancyBootstrapper; use Stancl\Tenancy\Contracts\Tenant; +/** + * This bootstrapper allows cache to be stored in the tenant databases by switching the database cache store's connection. + * Intended to be used with the 'database' cache store, instead of CacheTenancyBootstrapper. + * + * On bootstrap(), the database cache store's connection is set to 'tenant' + * and the database cache store is purged from the CacheManager's resolved stores. + * This forces the manager to resolve a new instance of the database store created with the 'tenant' DB connection on the next cache operation. + * + * On revert, the cache store's connection is reverted to the originally used one (usually 'central'), and again, + * the database cache store is purged from the CacheManager's resolved stores so that the originally used one is resolved on the next cache operation. + */ class DatabaseCacheBootstrapper implements TenancyBootstrapper { public function __construct(