function testStoreFetch() { $key = 'storekey2' . time(); $store = HandsetDetection\HDStore::getInstance(); $store->store($key, $this->testData); $cache = new HandsetDetection\HDCache(); $data = $cache->read($key); $this->assertEquals(false, $data); $data = $store->fetch($key); $this->assertEquals($this->testData, $data); $exists = is_file($store->directory . DIRECTORY_SEPARATOR . "{$key}.json"); $this->assertTrue($exists); }
function testVolume() { $cache = new HandsetDetection\HDCache(); $keys = array(); $now = time(); for ($i = 0; $i < 10000; $i++) { $key = 'test' . $now . $i; $cache->write($key, $this->testData); } for ($i = 0; $i < 10000; $i++) { $key = 'test' . $now . $i; $reply = $cache->read($key); $this->assertEquals($this->testData, $reply); } }
function testVolume() { $testDir = "/tmp/testdir"; if (!is_dir($testDir)) { mkdir($testDir); } $config = array('cache' => array('file' => array('directory' => $testDir))); $cache = new HandsetDetection\HDCache($config); $now = time(); for ($i = 0; $i < $this->volumeTest; $i++) { $key = 'test' . $now . $i; // Write $reply = $cache->write($key, $this->testData); $this->assertTrue($reply); // Read $reply = $cache->read($key); $this->assertEquals($this->testData, $reply); // Delete $reply = $cache->delete($key); $this->assertTrue($reply); // Read $reply = $cache->read($key); $this->assertNull($reply); } $end = time(); $cache->purge(); }
function testVolume() { $cache = new HandsetDetection\HDCache(); $now = time(); for ($i = 0; $i < $this->volumeTest; $i++) { $key = 'test' . $now . $i; // Write $reply = $cache->write($key, $this->testData); $this->assertTrue($reply); // Read $reply = $cache->read($key); $this->assertEquals($this->testData, $reply); // Delete $reply = $cache->delete($key); $this->assertTrue($reply); // Read $reply = $cache->read($key); $this->assertNull($reply); } $end = time(); $cache->purge(); }
function testPoolVolume() { $config = array('cache' => array('memcached' => array('pool' => 'mypool', 'options' => '', 'servers' => array(array('localhost', '11211'))))); $cache = new HandsetDetection\HDCache($config); $now = time(); for ($i = 0; $i < $this->volumeTest; $i++) { $key = 'test' . $now . $i; // Write $reply = $cache->write($key, $this->testData); $this->assertTrue($reply); // Read $reply = $cache->read($key); $this->assertEquals($this->testData, $reply); // Delete $reply = $cache->delete($key); $this->assertTrue($reply); // Read $reply = $cache->read($key); $this->assertNull($reply); } $end = time(); $cache->purge(); }
function testVolume() { $config = array('cache' => array('none' => true)); $cache = new HandsetDetection\HDCache($config); $now = time(); for ($i = 0; $i < $this->volumeTest; $i++) { $key = 'test' . $now . $i; // Write $reply = $cache->write($key, $this->testData); $this->assertFalse($reply); // Read $reply = $cache->read($key); $this->assertFalse($reply); // Delete $reply = $cache->delete($key); $this->assertFalse($reply); // Read $reply = $cache->read($key); $this->assertFalse($reply); } $end = time(); $cache->purge(); }
function testGetName() { $config = array('cache' => array('memcached' => array('pool' => 'mypool', 'options' => '', 'servers' => array(array('localhost', '11211'))))); $cache = new HandsetDetection\HDCache($config); $this->assertEquals('memcached', $cache->getName()); }
function testGetName() { $config = array('cache' => array('apc' => true)); $cache = new HandsetDetection\HDCache($config); $this->assertEquals('apc', $cache->getName()); }
function testGetName() { $cache = new HandsetDetection\HDCache(); $cacheNames = array('apc', 'apcu', 'memcache', 'memcached', 'file', 'none'); $this->assertContains($cache->getName(), $cacheNames); }