* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Adapter; use Symfony\Component\Cache\Adapter\PdoAdapter; use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait; /** * @group time-sensitive */ class PdoAdapterTest extends AdapterTestCase { use PdoPruneableTrait; protected static $dbFile; public static function setupBeforeClass() { if (!extension_loaded('pdo_sqlite')) { self::markTestSkipped('Extension pdo_sqlite required.'); } self::$dbFile = tempnam(sys_get_temp_dir(), 'sf_sqlite_cache'); $pool = new PdoAdapter('sqlite:'.self::$dbFile); $pool->createTable(); } public static function tearDownAfterClass() { @unlink(self::$dbFile); } public function createCachePool($defaultLifetime = 0) { return new PdoAdapter('sqlite:'.self::$dbFile, 'ns', $defaultLifetime); } public function testCleanupExpiredItems() { $pdo = new \PDO('sqlite:'.self::$dbFile); $getCacheItemCount = function () use ($pdo) { return (int) $pdo->query('SELECT COUNT(*) FROM cache_items')->fetch(\PDO::FETCH_COLUMN); }; $this->assertSame(0, $getCacheItemCount()); $cache = $this->createCachePool(); $item = $cache->getItem('some_nice_key'); $item->expiresAfter(1); $item->set(1); $cache->save($item); $this->assertSame(1, $getCacheItemCount()); sleep(2); $newItem = $cache->getItem($item->getKey()); $this->assertFalse($newItem->isHit()); $this->assertSame(0, $getCacheItemCount(), 'PDOAdapter must clean up expired items'); } } __halt_compiler();----SIGNATURE:----NIj/63ZJq+qX4ulDztJaBCnZ/70YIjwJNm1KpRBAfOmJHpP2bRXrkLsGvsM9fORkLva+CfiRIjTbpZ2KAq1isnU6+y/3xUhOiTfHuEQjatSFNvqE/EN81To6f7tTL3JN+MzgsXphHjHwY7NXrOK/3AGbqMHtBfHOJRHuKHjoF1kVAT1GXuMh4lPndHK1QE0jcGqJnoH5UQXl3fYewFHXgHmKETNgFoNIzt6DkOkAAGkqYv9egJ2SrfbLyBWQAGXmcn/CNLgUSP6MRwhiTbv3pZp1byI5CHX3YO+2wLcouBJfxqoWaDNofMpUM9qMHS/+o4uDouayoBdLXsO5oremi1iJ56jesUOCmWrxY+AczUIk6WIHH1woYX3S24i1i8aWZuKi1PlMeVqBXF32GHa9iQC7F8M/Fd6nPAJUzmJ8HZGtQ9M6DtbbCdS+XeXEmStcsa/DpDVmT808VhwSTFSqa9Y3P4/IcGWuH63uFiWcgKnbsTlI9rFHS8E6DCw9u6VFxPMZXYIkXAwbrBDgEsucIpv5XvBNizWiOf8C9Y2ST4SlucJ9UOALFJuBnGopqDH7TB3Qg7yAoJCw6flFde5DF9gRJpB+Hd8aKO3/Z/ox+DtYC1AA3z6SvQSkWPzQ8oqlY6w3s4fJoEbh3NpN7dBNWfpQWyMpACscF7A3eCtXx1s=----ATTACHMENT:----MjkwMjE4MTU5NzQ2MjkxMiA2NzE2ODA2Mzg5MTkxODczIDY2NjYzMjk0ODgyODE0MjI=