File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -195,7 +195,7 @@ protected function doFetch(array $ids)
195
195
foreach ($ expired as $ id ) {
196
196
$ stmt ->bindValue (++$ i , $ id );
197
197
}
198
- $ stmt ->execute ($ expired );
198
+ $ stmt ->execute ();
199
199
}
200
200
}
201
201
Original file line number Diff line number Diff line change @@ -41,4 +41,30 @@ public function createCachePool($defaultLifetime = 0)
41
41
{
42
42
return new PdoAdapter ('sqlite: ' .self ::$ dbFile , 'ns ' , $ defaultLifetime );
43
43
}
44
+
45
+ public function testCleanupExpiredItems ()
46
+ {
47
+ $ pdo = new \PDO ('sqlite: ' .self ::$ dbFile );
48
+
49
+ $ getCacheItemCount = function () use ($ pdo ) {
50
+ return (int ) $ pdo ->query ('SELECT COUNT(*) FROM cache_items ' )->fetch (\PDO ::FETCH_COLUMN );
51
+ };
52
+
53
+ $ this ->assertSame (0 , $ getCacheItemCount ());
54
+
55
+ $ cache = $ this ->createCachePool ();
56
+
57
+ $ item = $ cache ->getItem ('some_nice_key ' );
58
+ $ item ->expiresAfter (1 );
59
+ $ item ->set (1 );
60
+
61
+ $ cache ->save ($ item );
62
+ $ this ->assertSame (1 , $ getCacheItemCount ());
63
+
64
+ sleep (2 );
65
+
66
+ $ newItem = $ cache ->getItem ($ item ->getKey ());
67
+ $ this ->assertFalse ($ newItem ->isHit ());
68
+ $ this ->assertSame (0 , $ getCacheItemCount (), 'PDOAdapter must clean up expired items ' );
69
+ }
44
70
}
You can’t perform that action at this time.
0 commit comments