Пример #1
0
 public function testDataFileCacheDecrement()
 {
     $frontCache = new Phalcon\Cache\Frontend\Data();
     $cache = new Phalcon\Cache\Backend\File($frontCache, array('cacheDir' => 'unit-tests/cache/'));
     $cache->delete('foo');
     $cache->save('foo', "100");
     $this->assertEquals(99, $cache->decrement('foo'));
     $this->assertEquals(95, $cache->decrement('foo', 4));
 }
Пример #2
0
 public function _executeTestIssues2131($di)
 {
     $di->set('modelsCache', function () {
         $frontCache = new Phalcon\Cache\Frontend\Data();
         $modelsCache = new Phalcon\Cache\Backend\File($frontCache, array('cacheDir' => 'unit-tests/cache/'));
         $modelsCache->delete("cache-2131");
         return $modelsCache;
     }, true);
     $personas = Personas::query()->where("estado='I'")->cache(array("key" => "cache-2131"))->execute();
     $this->assertTrue($personas->isFresh());
     $personas = Personas::query()->where("estado='I'")->cache(array("key" => "cache-2131"))->execute();
     $this->assertFalse($personas->isFresh());
 }
Пример #3
0
 public function testIgbinaryFileCache()
 {
     if (!$this->_prepareIgbinary()) {
         return false;
     }
     $frontCache = new Phalcon\Cache\Frontend\Igbinary();
     $cache = new Phalcon\Cache\Backend\File($frontCache, array('cacheDir' => 'unit-tests/cache/'));
     $this->assertFalse($cache->isStarted());
     //Save
     $cache->save('test-data', "nothing interesting");
     $this->assertTrue(file_exists('unit-tests/cache/test-data'));
     //Get
     $cachedContent = $cache->get('test-data');
     $this->assertEquals($cachedContent, "nothing interesting");
     //Save
     $cache->save('test-data', "sure, nothing interesting");
     //Get
     $cachedContent = $cache->get('test-data');
     $this->assertEquals($cachedContent, "sure, nothing interesting");
     //More complex save/get
     $data = array('null' => null, 'array' => array(1, 2, 3, 4 => 5), 'string', 123.45, 6, true, false, null, 0, "");
     $serialized = igbinary_serialize($data);
     $this->assertEquals($data, igbinary_unserialize($serialized));
     $cache->save('test-data', $data);
     $cachedContent = $cache->get('test-data');
     $this->assertEquals($cachedContent, $data);
     //Exists
     $this->assertTrue($cache->exists('test-data'));
     //Delete
     $this->assertTrue($cache->delete('test-data'));
 }