Exemplo n.º 1
0
 public function testXcacheQueryKeys()
 {
     $ready = $this->_prepareXcache();
     if (!$ready) {
         return false;
     }
     $frontCache = new Phalcon\Cache\Frontend\None(array('lifetime' => 2));
     $cache = new Phalcon\Cache\Backend\Xcache($frontCache);
     $cache->delete('test-output');
     $cache->delete('test-data');
     $cache->save('test-one', 'one');
     $cache->save('test-two', 'two');
     //Query keys
     $keys = $cache->queryKeys();
     $this->assertEquals($keys, array(0 => 'test-one', 1 => 'test-two'));
 }
Exemplo n.º 2
0
 public function testCacheXcacheFlush()
 {
     $frontCache = new Phalcon\Cache\Frontend\Data(array('lifetime' => 10));
     // Xcache
     $ready = $this->_prepareXcache();
     if (!$ready) {
         return false;
     }
     $cache = new Phalcon\Cache\Backend\Xcache($frontCache, array('statsKey' => '_PHCM'));
     $cache->save('data', "1");
     $cache->save('data2', "2");
     $this->assertTrue($cache->flush());
     $this->assertFalse($cache->exists('data'));
     $this->assertFalse($cache->exists('data2'));
 }
<?php

//Cache data for 2 days
$frontCache = new Phalcon\Cache\Frontend\Data(array('lifetime' => 172800));
$cache = new Phalcon\Cache\Backend\Xcache($frontCache, array('prefix' => 'app-data'));
//Cache arbitrary data
$cache->save('my-data', array(1, 2, 3, 4, 5));
//Get data
$data = $cache->get('my-data');