File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,8 @@ protected function fetchObjectFromCache($key)
4646
4747 $ data = unserialize ($ this ->filesystem ->read ($ file ));
4848 if ($ data [0 ] !== null && time () > $ data [0 ]) {
49+ $ this ->clearOneObjectFromCache ($ key );
50+
4951 return [false , null ];
5052 }
5153
Original file line number Diff line number Diff line change @@ -27,4 +27,21 @@ public function testInvalidKey()
2727
2828 $ pool ->getItem ('test%string ' )->get ();
2929 }
30+
31+ public function testCleanupOnExpire ()
32+ {
33+ $ pool = $ this ->createCachePool ();
34+
35+ $ item = $ pool ->getItem ('test_ttl_null ' );
36+ $ item ->set ('data ' );
37+ $ item ->expiresAt (new \DateTime ('now ' ));
38+ $ pool ->save ($ item );
39+ $ this ->assertTrue ($ this ->getFilesystem ()->has ('cache/test_ttl_null ' ));
40+
41+ sleep (1 );
42+
43+ $ item = $ pool ->getItem ('test_ttl_null ' );
44+ $ this ->assertFalse ($ item ->isHit ());
45+ $ this ->assertFalse ($ this ->getFilesystem ()->has ('cache/test_ttl_null ' ));
46+ }
3047}
You can’t perform that action at this time.
0 commit comments