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

[4.x] Support database cache store tenancy (#1290) (resolve #852)

* Initial implementation (lukinovec)

* Make sure DatabaseCacheBootstrapper runs after DatabaseTenancyBootstrapper, misc wip changes

* Fix withTenantDatabases()

* Add failing test (GlobalCacheTest)

* Configure globalCache's DB stores to use central connection instead of default connection every time it's reinstantiated

* Make GlobalCache facade not cached. Even though it wasn't causing issues
in our existing tests, it likely was flaky, and making it not $cached
makes it now consistent with global_cache() - always getting a new
CacheManager from the globalCache container binding

* Add database connection assertions in GlobalCacheTest

* Run all cached resolver/global cache tests with DatabaseCacheBootstrapper

* Reset adjustCacheManagerUsing in revert() and TestCase

* Reset static $stores property

* Finalize GlobalCache-related changes

* tests: remove pointless cache TTLs

* Refactor DatabaseCacheBootstrapper

* Refactor tests

Co-authored-by: lukinovec <lukinovec@gmail.com>
This commit is contained in:
Samuel Štancl 2025-08-08 00:54:01 +02:00
parent 3984d64cfa
commit ecc3374293
14 changed files with 600 additions and 38 deletions

View file

@ -56,7 +56,7 @@ test('tags separate cache properly', function () {
$tenant1 = Tenant::create();
tenancy()->initialize($tenant1);
cache()->put('foo', 'bar', 1);
cache()->put('foo', 'bar');
expect(cache()->get('foo'))->toBe('bar');
$tenant2 = Tenant::create();
@ -64,7 +64,7 @@ test('tags separate cache properly', function () {
expect(cache('foo'))->not()->toBe('bar');
cache()->put('foo', 'xyz', 1);
cache()->put('foo', 'xyz');
expect(cache()->get('foo'))->toBe('xyz');
});
@ -72,7 +72,7 @@ test('invoking the cache helper works', function () {
$tenant1 = Tenant::create();
tenancy()->initialize($tenant1);
cache(['foo' => 'bar'], 1);
cache(['foo' => 'bar']);
expect(cache('foo'))->toBe('bar');
$tenant2 = Tenant::create();
@ -80,7 +80,7 @@ test('invoking the cache helper works', function () {
expect(cache('foo'))->not()->toBe('bar');
cache(['foo' => 'xyz'], 1);
cache(['foo' => 'xyz']);
expect(cache('foo'))->toBe('xyz');
});
@ -88,7 +88,7 @@ test('cache is persisted', function () {
$tenant1 = Tenant::create();
tenancy()->initialize($tenant1);
cache(['foo' => 'bar'], 10);
cache(['foo' => 'bar']);
expect(cache('foo'))->toBe('bar');
tenancy()->end();
@ -102,7 +102,7 @@ test('cache is persisted when reidentification is used', function () {
$tenant2 = Tenant::create();
tenancy()->initialize($tenant1);
cache(['foo' => 'bar'], 10);
cache(['foo' => 'bar']);
expect(cache('foo'))->toBe('bar');
tenancy()->initialize($tenant2);