File tree 2 files changed +19
-0
lines changed
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)
46
46
47
47
$ data = unserialize ($ this ->filesystem ->read ($ file ));
48
48
if ($ data [0 ] !== null && time () > $ data [0 ]) {
49
+ $ this ->clearOneObjectFromCache ($ key );
50
+
49
51
return [false , null ];
50
52
}
51
53
Original file line number Diff line number Diff line change @@ -27,4 +27,21 @@ public function testInvalidKey()
27
27
28
28
$ pool ->getItem ('test%string ' )->get ();
29
29
}
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
+ }
30
47
}
You can’t perform that action at this time.
0 commit comments