Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefixing cache doesn't work fine with file-store #484

Closed
kienngd opened this issue Aug 18, 2023 · 3 comments
Closed

Prefixing cache doesn't work fine with file-store #484

kienngd opened this issue Aug 18, 2023 · 3 comments

Comments

@kienngd
Copy link

kienngd commented Aug 18, 2023

In your document:

cache()->put('key', 'original-value');

$tenant->makeCurrent();
cache('key') // returns null;
cache()->put('key', 'value-for-tenant');

$anotherTenant->makeCurrent();
cache('key') // returns null;
cache()->put('key', 'value-for-another-tenant');

Tenant::forgetCurrent();
cache('key') // returns 'original-value';

$tenant->makeCurrent();
cache('key') // returns 'value-for-tenant'

$anotherTenant->makeCurrent();
cache('key') // returns 'value-for-another-tenant'

If default cache store is file, it doesn't work.
I see in file: vendor/spatie/laravel-multitenancy/src/Tasks/PrefixCacheTask.php maybe you should config()->set('cache.stores.file.path', $cacheFilePath); too

@masterix21
Copy link
Collaborator

Hi @kienngd, you can't use the prefix when the cache store is "file".

@kienngd
Copy link
Author

kienngd commented Aug 23, 2023

Yes, I understand we can't use prefix when the cache is "file" so I suggest use custom store-file-path for each tenant instead

@masterix21
Copy link
Collaborator

Feel free to create a well-tested PR and I will be happy to merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants