Skip to content

Cache invalidation affects different Cache instances #74

Open
@KminekMatej

Description

@KminekMatej

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions