mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 17:44:04 +00:00
Disable cache tagging by default, add CacheTagBootstrapper
This commit is contained in:
parent
5849afa4c8
commit
7ebfc375d6
5 changed files with 31 additions and 12 deletions
22
src/Bootstrappers/CacheTagBootstrapper.php
Normal file
22
src/Bootstrappers/CacheTagBootstrapper.php
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Stancl\Tenancy\Bootstrappers;
|
||||
|
||||
use Stancl\Tenancy\CacheManager;
|
||||
use Stancl\Tenancy\Contracts\Tenant;
|
||||
use Stancl\Tenancy\Contracts\TenancyBootstrapper;
|
||||
|
||||
class CacheTagBootstrapper implements TenancyBootstrapper
|
||||
{
|
||||
public function bootstrap(Tenant $tenant): void
|
||||
{
|
||||
CacheManager::$addTags = true;
|
||||
}
|
||||
|
||||
public function revert(): void
|
||||
{
|
||||
CacheManager::$addTags = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@ use Illuminate\Cache\CacheManager as BaseCacheManager;
|
|||
|
||||
class CacheManager extends BaseCacheManager
|
||||
{
|
||||
public static bool $addTags = true;
|
||||
public static bool $addTags = false;
|
||||
|
||||
/**
|
||||
* Add tags and forward the call to the inner cache store.
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ use Illuminate\Support\Facades\DB;
|
|||
use Illuminate\Support\Facades\URL;
|
||||
use Stancl\JobPipeline\JobPipeline;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Stancl\Tenancy\Bootstrappers\PrefixCacheTenancyBootstrapper;
|
||||
use Stancl\Tenancy\Tests\Etc\Tenant;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
|
|
@ -29,6 +28,7 @@ use Stancl\Tenancy\Listeners\BootstrapTenancy;
|
|||
use Stancl\Tenancy\Tests\Etc\TestingBroadcaster;
|
||||
use Stancl\Tenancy\Listeners\DeleteTenantStorage;
|
||||
use Stancl\Tenancy\Listeners\RevertToCentralContext;
|
||||
use Stancl\Tenancy\Bootstrappers\CacheTagBootstrapper;
|
||||
use Stancl\Tenancy\Bootstrappers\UrlTenancyBootstrapper;
|
||||
use Stancl\Tenancy\Bootstrappers\MailTenancyBootstrapper;
|
||||
use Stancl\Tenancy\Bootstrappers\RedisTenancyBootstrapper;
|
||||
|
|
@ -36,7 +36,6 @@ use Stancl\Tenancy\Middleware\InitializeTenancyBySubdomain;
|
|||
use Stancl\Tenancy\Bootstrappers\DatabaseTenancyBootstrapper;
|
||||
use Stancl\Tenancy\Bootstrappers\BroadcastTenancyBootstrapper;
|
||||
use Stancl\Tenancy\Bootstrappers\FilesystemTenancyBootstrapper;
|
||||
use Stancl\Tenancy\CacheManager;
|
||||
|
||||
beforeEach(function () {
|
||||
$this->mockConsoleOutput = false;
|
||||
|
|
@ -84,11 +83,9 @@ test('database data is separated', function () {
|
|||
});
|
||||
|
||||
test('cache data is separated', function () {
|
||||
CacheManager::$addTags = true;
|
||||
|
||||
config([
|
||||
'tenancy.bootstrappers' => [
|
||||
PrefixCacheTenancyBootstrapper::class,
|
||||
CacheTagBootstrapper::class,
|
||||
],
|
||||
'cache.default' => 'redis',
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -2,16 +2,15 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Stancl\Tenancy\CacheManager;
|
||||
use Stancl\Tenancy\Tests\Etc\Tenant;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Stancl\Tenancy\Events\TenancyInitialized;
|
||||
use Stancl\Tenancy\Listeners\BootstrapTenancy;
|
||||
use Stancl\Tenancy\Bootstrappers\CacheTagBootstrapper;
|
||||
|
||||
beforeEach(function () {
|
||||
config(['tenancy.bootstrappers' => []]);
|
||||
config(['tenancy.bootstrappers' => [CacheTagBootstrapper::class]]);
|
||||
|
||||
CacheManager::$addTags = true;
|
||||
Event::listen(TenancyInitialized::class, BootstrapTenancy::class);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -2,16 +2,17 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Stancl\Tenancy\Tests\Etc\Tenant;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Stancl\Tenancy\Events\TenancyEnded;
|
||||
use Stancl\Tenancy\Events\TenancyInitialized;
|
||||
use Stancl\Tenancy\Facades\GlobalCache;
|
||||
use Stancl\Tenancy\Events\TenancyInitialized;
|
||||
use Stancl\Tenancy\Listeners\BootstrapTenancy;
|
||||
use Stancl\Tenancy\Listeners\RevertToCentralContext;
|
||||
use Stancl\Tenancy\Tests\Etc\Tenant;
|
||||
use Stancl\Tenancy\Bootstrappers\CacheTagBootstrapper;
|
||||
|
||||
beforeEach(function () {
|
||||
config(['tenancy.bootstrappers' => []]);
|
||||
config(['tenancy.bootstrappers' => [CacheTagBootstrapper::class]]);
|
||||
|
||||
Event::listen(TenancyInitialized::class, BootstrapTenancy::class);
|
||||
Event::listen(TenancyEnded::class, RevertToCentralContext::class);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue