You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There was a change in the TagAwareAdapter from version 4.0.8 to 4.0.9 which seems to break the tag invalidation. I included a unit test which runs fine with version 4.0.8 of the cache component but breaks with version 4.0.9.
Expected behavior (this is how it works in 4.0.8)
Get cache key "item1" (isHit == false)
Write a cache key "item1" with "tag1"
Get cache key (isHit == true)
Invalidate tag "tag1"
Get cache key (isHit == false)
Now get the key in a new request, simulated by $tagAwareAdapter2 = new TagAwareAdapter), and get will result in a isHit == false.
Actual behavior (right now in 4.0.9)
Get cache key "item1" (isHit == false)
Write a cache key "item1" with "tag1"
Get cache key (isHit == true)
Invalidate tag "tag1"
Get cache key (isHit == false)
Now get the key in a new request, simulated by $tagAwareAdapter2 = new TagAwareAdapter), and get will result in a isHit == true.
You can use this unit test to reproduce
<?php
namespace App\Tests;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
class TagCacheTest extends KernelTestCase
{
const ITEM = 'item1';
const TAG = 'tag1';
public function testInvalidateTags()
{
$tagAwareAdapter1 = new TagAwareAdapter(new FilesystemAdapter('', 0));
$tagAwareAdapter1->clear();
$cacheItem1 = $tagAwareAdapter1->getItem(self::ITEM);
$this->assertFalse($cacheItem1->isHit(), 'Item should not have been hit (1)');
$cacheItem1->tag([self::TAG]);
$cacheItem1->set('this is the value of [' . self::ITEM . ']');
$saved = $tagAwareAdapter1->save($cacheItem1);
$this->assertTrue($saved);
$cacheItem2 = $tagAwareAdapter1->getItem(self::ITEM);
$this->assertTrue($cacheItem2->isHit(), 'Item should have been hit');
$success = $tagAwareAdapter1->invalidateTags([self::TAG]);
$this->assertTrue($success);
$cacheItem3 = $tagAwareAdapter1->getItem(self::ITEM);
$this->assertFalse($cacheItem3->isHit(), 'Item should not have been hit (2)');
$tagAwareAdapter2 = new TagAwareAdapter(new FilesystemAdapter('', 0));
$cacheItem4 = $tagAwareAdapter2->getItem(self::ITEM);
$this->assertFalse($cacheItem4->isHit(), 'Item should not have been hit (3)');
}
}
The text was updated successfully, but these errors were encountered:
There was a change in the TagAwareAdapter from version 4.0.8 to 4.0.9 which seems to break the tag invalidation. I included a unit test which runs fine with version 4.0.8 of the cache component but breaks with version 4.0.9.
Expected behavior (this is how it works in 4.0.8)
$tagAwareAdapter2 = new TagAwareAdapter
), and get will result in a isHit == false.Actual behavior (right now in 4.0.9)
$tagAwareAdapter2 = new TagAwareAdapter
), and get will result in a isHit == true.You can use this unit test to reproduce
The text was updated successfully, but these errors were encountered: