Allows to cache output fragments, PHP data or raw data to a Aerospike backend. use Phalcon\Cache\Frontend\Data; use Phalcon\Cache\Backend\Aerospike as CacheBackend; Cache data for 2 days $frontCache = new Data(['lifetime' => 172800]); Create the Cache setting redis connection options $cache = new CacheBackend($frontCache, [ 'hosts' => [ ['addr' => '127.0.0.1', 'port' => 3000] ], 'persistent' => true, 'namespace' => 'test', 'prefix' => 'cache_', 'options' => [ \Aerospike::OPT_CONNECT_TIMEOUT => 1250, \Aerospike::OPT_WRITE_TIMEOUT => 1500 ] ]); Cache arbitrary data $cache->save('my-data', [1, 2, 3, 4, 5]); Get data $data = $cache->get('my-data');
Inheritance: extends Phalcon\Cache\Backend, implements Phalcon\Cache\BackendInterface, use trait Prefixable
コード例 #1
0
ファイル: Aerospike.php プロジェクト: phalcon/incubator
 /**
  * {@inheritdoc}
  *
  * @param string $sessionId Session variable name [Optional]
  * @return bool
  */
 public function destroy($sessionId = null)
 {
     if (null === $sessionId) {
         $sessionId = $this->getId();
     }
     if (!isset($_SESSION) || !is_array($_SESSION)) {
         $_SESSION = [];
     }
     foreach ($_SESSION as $id => $key) {
         unset($_SESSION[$id]);
     }
     return $this->db->delete($sessionId);
 }
コード例 #2
0
ファイル: AerospikeTest.php プロジェクト: Zaszczyk/incubator
 public function testShouldUseOutputFrontend()
 {
     $time = date('H:i:s');
     $frontCache = new CacheOutput(['lifetime' => 10]);
     $cache = new CacheAerospike($frontCache, $this->getConfig());
     ob_start();
     $content = $cache->start('test-output');
     $this->keys[] = 'test-output';
     $this->assertNull($content);
     echo $time;
     $obContent = ob_get_contents();
     $cache->save(null, null, null, true);
     ob_end_clean();
     $this->assertEquals($time, $obContent);
     $this->assertEquals($time, $cache->get('test-output'));
     $content = $cache->start('test-output');
     $this->assertEquals($content, $obContent);
     $this->assertEquals($content, $cache->get('test-output'));
     $keys = $cache->queryKeys();
     $this->assertEquals([0 => 'test-output'], $keys);
 }
コード例 #3
0
ファイル: Aerospike.php プロジェクト: Zaszczyk/incubator
 /**
  * Generates a unique key used for storing cache data in Aerospike DB.
  *
  * @param string $key Cache key
  * @return array
  */
 protected function buildKey($key)
 {
     return $this->db->initKey($this->namespace, $this->set, $key);
 }