protected function _startcallback(CacheAbstract $cache) { $key = new CacheKey("startcallback", 1); $cache->clean($key); $this->assertFalse($cache->start($key)); echo "something "; $this->assertTrue($cache->appendCallback('callbackTesterStart')); echo " otherthing"; $output = $cache->end(false); $this->assertContains(CALLBACKVALUE, $output); // run again, we should have another value $second = $cache->start($key, null, false); $this->assertNotFalse($second); $this->assertContains(CALLBACKVALUE, $second); $this->assertNotEquals($second, $output); }
private function getStoreData(CacheAbstract $cache) { $base = 'base'; $this->assertTrue($cache->isEnabled()); $cache->setDefaultLifetime(3600); $this->assertEquals(3600, $cache->getDefaultLifetime()); // clean $key1 = new CacheKey($base, 1); $cache->clean($key1); // nothing there try { $data = $cache->get($key1); $this->fail(); } catch (Cachearium\Exceptions\NotCachedException $e) { $this->assertTrue(true); } // store $cd = new CacheData($key1, 234); $retval = $cache->storeData($cd); $this->assertTrue($retval); // get try { $data = $cache->getData($key1); $this->assertInstanceOf('Cachearium\\CacheData', $data); $this->assertEquals(234, $data->getFirstData()); } catch (Cachearium\Exceptions\NotCachedException $e) { $this->fail(); } // ivalid try { $data2 = $cache->getDataP("some", "random", "stuff"); $this->fail(); } catch (Cachearium\Exceptions\NotCachedException $e) { $this->assertTrue(true); } sleep(1); try { $data = $cache->getData($key1); $this->assertInstanceOf('Cachearium\\CacheData', $data); $this->assertEquals(234, $data->getFirstData()); } catch (Cachearium\Exceptions\NotCachedException $e) { $this->fail(); } // clean $cache->clean($key1); try { $data = $cache->getData($key1); $this->fail(); } catch (Cachearium\Exceptions\NotCachedException $e) { $this->assertTrue(true); } // check conflicts $key2 = new CacheKey($base, 2, 'a'); $key3 = new CacheKey($base, 3, 'a'); // now change again and delete $retval = $cache->storeData(new CacheData($key2, 234)); $this->assertEquals(true, $retval); try { $data = $cache->getData($key2); $this->assertInstanceOf('Cachearium\\CacheData', $data); $this->assertEquals(234, $data->getFirstData()); } catch (Cachearium\Exceptions\NotCachedException $e) { $this->fail(); } $this->assertTrue($cache->delete($key2)); // test null $retval = $cache->storeData(new CacheData($key3), null); $this->assertEquals(true, $retval); try { $data = $cache->getData($key3); $this->assertInstanceOf('Cachearium\\CacheData', $data); $this->assertEquals(null, $data->getFirstData()); } catch (Cachearium\Exceptions\NotCachedException $e) { $this->fail(); } $this->assertTrue($cache->delete($key3)); }