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

Cache invalidation affects different Cache instances #74

Open
KminekMatej opened this issue Nov 29, 2023 · 0 comments
Open

Cache invalidation affects different Cache instances #74

KminekMatej opened this issue Nov 29, 2023 · 0 comments

Comments

@KminekMatej
Copy link
Contributor

Version: 3.2.2

Bug Description

https://forum.nette.org/cs/36236-cache-invalidace-podle-patternu#p225445

$cache1 = new Cache($this->cacheStorage, 1);
$cache2 = new Cache($this->cacheStorage, 2);

$cache1->save("key1-1", "value-1-1", [Cache::Priority => 1]);

$cache2->save("key2-1", "value-2-1", [Cache::Priority => 1]);
$cache1->clean([
    Cache::Priority => 1
]);

Assert::null($cache1->load("key1-1"));
Assert::notNull($cache2->load("key2-1")); // Tester\AssertException: Value should not be null

Expected Behavior

Cache1 should not be involved in cleaning of Cache2 - since they have different namespace.

Possible Solution

Problem lies when both caches shares same Storage. Storage returns simply keys without respect to namespace. Namespace should probably be stored in cache storage and cleaning function should pay respect to that namespace.

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

1 participant