Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Cache] CacheItem with tag is never a hit after expired #36457

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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add reproducer to for hit after update expire cacheItem
  • Loading branch information
alexander-schranz authored and nicolas-grekas committed Apr 18, 2020
commit d082eca7ddde683fd8e0be56f13f4b865dc6294d
38 changes: 38 additions & 0 deletions 38 src/Symfony/Component/Cache/Tests/Traits/TagAwareTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,42 @@ public function testGetMetadata()
$i = $pool->getItem('k');
$this->assertSame(['foo' => 'foo'], $i->getMetadata()[CacheItem::METADATA_TAGS]);
}

public function testRefreshAfterExpires()
{
$pool = $this->createCachePool();
$pool->clear();

$cacheItem = $pool->getItem('test');

$this->assertFalse($cacheItem->isHit());

// write cache with expires
$cacheItem->set('test');
$cacheItem->tag('1234');
$cacheItem->expiresAfter(1);

$pool->save($cacheItem);

$cacheItem = $pool->getItem('test');
$this->assertTrue($cacheItem->isHit());

// wait until expired
sleep(2);

// item should not longer be a hit
$cacheItem = $pool->getItem('test');
$this->assertFalse($cacheItem->isHit());

// update expired item
$cacheItem->set('test');
$cacheItem->tag('1234');
$cacheItem->expiresAfter(1);

$pool->save($cacheItem);

// item should be again a hit
$cacheItem = $pool->getItem('test');
$this->assertTrue($cacheItem->isHit());
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.