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

Commit f8a8eb1

Browse filesBrowse files
Add reproducer to for hit after update expire cacheItem
1 parent 39a7ee1 commit f8a8eb1
Copy full SHA for f8a8eb1

File tree

Expand file treeCollapse file tree

1 file changed

+38
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+38
-0
lines changed

‎src/Symfony/Component/Cache/Tests/Traits/TagAwareTestTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Tests/Traits/TagAwareTestTrait.php
+38Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,42 @@ public function testGetMetadata()
155155
$i = $pool->getItem('k');
156156
$this->assertSame(['foo' => 'foo'], $i->getMetadata()[CacheItem::METADATA_TAGS]);
157157
}
158+
159+
public function testRefreshAfterExpires()
160+
{
161+
$pool = $this->createCachePool();
162+
$pool->clear();
163+
164+
$cacheItem = $pool->getItem('test');
165+
166+
$this->assertFalse($cacheItem->isHit());
167+
168+
// write cache with expires
169+
$cacheItem->set('test');
170+
$cacheItem->tag('1234');
171+
$cacheItem->expiresAfter(5);
172+
173+
$pool->save($cacheItem);
174+
175+
$cacheItem = $pool->getItem('test');
176+
$this->assertTrue($cacheItem->isHit());
177+
178+
// wait until expired
179+
sleep(5);
180+
181+
// item should not longer be a hit
182+
$cacheItem = $pool->getItem('test');
183+
$this->assertFalse($cacheItem->isHit());
184+
185+
// update expired item
186+
$cacheItem->set('test');
187+
$cacheItem->tag('1234');
188+
$cacheItem->expiresAfter(5);
189+
190+
$pool->save($cacheItem);
191+
192+
// item should be again a hit
193+
$cacheItem = $pool->getItem('test');
194+
$this->assertTrue($cacheItem->isHit());
195+
}
158196
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.