mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 20:34:03 +00:00
Cache prefixing logic rewrite, session scoping improvements, tests refactor (#43)
* Run cache tests on all supported drivers * update ci healthcheck for memcached * remove memcached healthcheck * fix typos in test comments, expand internal.md [ci skip] * add empty line [ci skip] * switch to using $store->setPrefix() * add dynamodb * refactor try-finally to try-catch * remove unnecessary clearResolvedInstances() call * add dual Cache:: and cache() assertions * add apc * Flush APCu cache in test setup * Revert "add dual Cache:: and cache() assertions" This reverts commit a0bab162fbe2dd0d25e7056ceca4fb7ce54efc77. * phpstan fix * Add logic for scoping 'file' disks to FilesystemTenancyBootstrapper * minor changes, add todos * refactor how the session.connection is used in the DB session bootstrapper * add session forgery prevention logic to the db session bootstrapper * only use the fs bootstrapper for file disk in 'cache data is separated' dataset * minor session scoping test changes * Add session scoping logic to FilesystemTenancyBootstrapper, correctly update disk roots even with storage_path_tenancy disabled * Fix code style (php-cs-fixer) * update docblock * make not-null check more explicit * separate bootstrapper tests, fix swapped test names for two tests * refactor cache bootstrapper tests * resolve global cache todo * expand tests: session separation tests, more filesystem separation assertions; change prefix_base-type config keys to templates/formats * add apc session scoping test, various session separation bugfixes * phpstan + minor logic fixes * prefix_format -> prefix * fix database session separation test * revert composer.json changes, update laravel dependencies to expected next release * only run session scoping logic in cache bootstrapper for redis, memcached, dynamodb, apc; update gitattributes * tenancy.central_domains -> tenancy.identification.central_domains * db session separation test: add datasets --------- Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
This commit is contained in:
parent
943b960718
commit
eecf6f21c8
40 changed files with 1856 additions and 1177 deletions
|
|
@ -38,16 +38,16 @@ return [
|
|||
'id_generator' => UniqueIdentifierGenerators\UUIDGenerator::class,
|
||||
],
|
||||
|
||||
/**
|
||||
* The list of domains hosting your central app.
|
||||
*
|
||||
* Only relevant if you're using the domain or subdomain identification middleware.
|
||||
*/
|
||||
'central_domains' => [
|
||||
str(env('APP_URL'))->after('://')->before('/')->toString(),
|
||||
],
|
||||
|
||||
'identification' => [
|
||||
/**
|
||||
* The list of domains hosting your central app.
|
||||
*
|
||||
* Only relevant if you're using the domain or subdomain identification middleware.
|
||||
*/
|
||||
'central_domains' => [ // todo@docs this was moved into the identification section
|
||||
str(env('APP_URL'))->after('://')->before('/')->toString(),
|
||||
],
|
||||
|
||||
/**
|
||||
* The default middleware used for tenant identification.
|
||||
*
|
||||
|
|
@ -222,11 +222,18 @@ return [
|
|||
* You can clear cache selectively by specifying the tag.
|
||||
*/
|
||||
'cache' => [
|
||||
'prefix_base' => 'tenant', // This prefix_base, followed by the tenant_id, will form a cache prefix that will be used for every cache key.
|
||||
'prefix' => 'tenant_%tenant%_', // This format, with the %tenant% replaced by the tenant key, and prepended by the original store prefix, will form a cache prefix that will be used for every cache key.
|
||||
'stores' => [
|
||||
env('CACHE_STORE'),
|
||||
],
|
||||
|
||||
/*
|
||||
* Should sessions be tenant-aware (only used when your session driver is cache-based).
|
||||
*
|
||||
* Note: This will implicitly add your configured session store to the list of prefixed stores above.
|
||||
*/
|
||||
'scope_sessions' => true,
|
||||
|
||||
'tag_base' => 'tenant', // This tag_base, followed by the tenant_id, will form a tag that will be applied on each cache call.
|
||||
],
|
||||
|
||||
|
|
@ -273,6 +280,20 @@ return [
|
|||
'public' => 'public-%tenant%',
|
||||
],
|
||||
|
||||
/*
|
||||
* Should the `file` cache driver be tenant-aware.
|
||||
*
|
||||
* When this is enabled, cache files will be stored in storage/{tenant}/framework/cache.
|
||||
*/
|
||||
'scope_cache' => true,
|
||||
|
||||
/*
|
||||
* Should the `file` session driver be tenant-aware.
|
||||
*
|
||||
* When this is enabled, session files will be stored in storage/{tenant}/framework/sessions.
|
||||
*/
|
||||
'scope_sessions' => true,
|
||||
|
||||
/**
|
||||
* Should storage_path() be suffixed.
|
||||
*
|
||||
|
|
@ -304,7 +325,7 @@ return [
|
|||
* either using the Redis facade or by injecting it as a dependency.
|
||||
*/
|
||||
'redis' => [
|
||||
'prefix_base' => 'tenant', // Each key in Redis will be prepended by this prefix_base, followed by the tenant id.
|
||||
'prefix' => 'tenant_%tenant%_', // Each key in Redis will be prepended by this prefix format, with %tenant% replaced by the tenant key.
|
||||
'prefixed_connections' => [ // Redis connections whose keys are prefixed, to separate one tenant's keys from another.
|
||||
'default',
|
||||
// 'cache', // Enable this if you want to scope cache using RedisTenancyBootstrapper
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue