public function testGetVersion() { if (class_exists('Memcache')) { $c = Cache::factory(new Memcached(), 30); $this->assertNotNull($c->adapter()->getVersion()); } }
public function testGetInfo() { if (function_exists('apc_add')) { $c = Cache::factory(new Apc(), 30); $this->assertTrue(is_array($c->adapter()->getInfo())); } }
public function testSaveAndLoad() { if (!file_exists(__DIR__ . '/../tmp/cache')) { mkdir(__DIR__ . '/../tmp/cache'); chmod(__DIR__ . '/../tmp/cache', 0777); } $str = 'This is my test variable. It contains a string.'; $c = Cache::factory(new File(__DIR__ . '/../tmp/cache'), 30); $this->fileExists($c->adapter()->getDir()); $c->save('str', $str); $this->assertEquals($str, $c->load('str')); $c->remove('str'); $c->clear(); if (file_exists(__DIR__ . '/../tmp/cache')) { rmdir(__DIR__ . '/../tmp/cache'); } }
<?php require_once '../../bootstrap.php'; use Pop\Cache; try { $cache = Cache\Cache::factory(new Cache\Adapter\File('../tmp'), 30); //$cache = Cache\Cache::factory(new Cache\Adapter\Memcached(), 30); //$cache = Cache\Cache::factory(new Cache\Adapter\Sqlite('../tmp/cache.sqlite'), 30); //$cache = Cache\Cache::factory(new Cache\Adapter\Apc(), 30); if (!($var = $cache->load('test'))) { echo 'It\'s either not there or expired.'; } else { echo $var; } } catch (\Exception $e) { echo $e->getMessage() . PHP_EOL . PHP_EOL; }
public function testDelete() { $c = Cache::factory(new Sqlite(__DIR__ . '/../tmp/cache.sqlite'), 30); $c->adapter()->delete(); $this->assertFalse(file_exists(__DIR__ . '/../tmp/cache.sqlite')); }