public function init($config) { global $_G; $this->obj = Alibaba::Cache($config); $this->enable = $this->obj ? true : false; $this->config = $config; return $this->enable; }
/** * @return Memcache|the */ public function getMemCache() { if ($this->_cache === null) { if (class_exists('Alibaba', false)) { $this->_cache = Alibaba::Cache('memcache'); } else { $memcache = new CMemCache(); $memcache->setServers($this->_servers); $memcache->init(); $this->_cache = $memcache; } } return $this->_cache; }
public function __construct() { $this->memcache = Alibaba::Cache('rsscabbitme'); }
public function __construct() { parent::__construct(); $this->sign(); $this->cache = \Alibaba::Cache(); }
function __constructor() { $this->cache = Alibaba::Cache(); session_set_save_handler(array($this, 'openSession'), array($this, 'closeSession'), array($this, 'readSession'), array($this, 'writeSession'), array($this, 'destroySession'), array($this, 'gcSession')); }
<?php function test($val, $expect, $msg) { if ($val != $expect) { throw new Exception($msg); } } $cache = Alibaba::Cache(); $user = array("name" => "ace", "age" => 1, "sex" => "male"); test($cache->set('user', $user), true, 'Set cache failed'); test($cache->get('user')['age'], 1, 'Get cache failed'); test($cache->set('foo', 1), true, 'Set cache failed'); test($cache->add('foo', 1), false, 'Add cache failed'); test($cache->delete('foo'), true, 'Add cache failed'); test($cache->add('foo', 1), true, 'Add cache failed'); test($cache->increment('foo', 1), 2, 'increment cache failed'); test($cache->decrement('foo', 1), 1, 'decrement cache failed'); echo '测试完成.';