File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
src/Symfony/Component/Cache/Tests/Traits Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -155,4 +155,42 @@ public function testGetMetadata()
155
155
$ i = $ pool ->getItem ('k ' );
156
156
$ this ->assertSame (['foo ' => 'foo ' ], $ i ->getMetadata ()[CacheItem::METADATA_TAGS ]);
157
157
}
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
+ }
158
196
}
You can’t perform that action at this time.
0 commit comments