21 defined(
'XOOPS_ROOT_PATH') or die('Restricted access');
71 var $settings = array();
82 function init($settings = array())
84 if (!class_exists(
'Memcache')) {
87 parent::init($settings);
92 $this->settings = array_merge($defaults, $this->settings);
94 if (!$this->settings[
'compress']) {
95 $this->settings[
'compress'] = MEMCACHE_COMPRESSED;
97 if (!is_array($this->settings[
'servers'])) {
98 $this->settings[
'servers'] = array(
99 $this->settings[
'servers']);
101 $this->memcache = null;
102 $this->memcache =
new Memcache();
103 foreach ($this->settings[
'servers'] as $server) {
104 $parts = explode(
':', $server);
107 if (isset($parts[1])) {
110 if ($this->memcache->addServer($host, $port)) {
125 function write($key, &$value, $duration)
127 return $this->memcache->set($key, $value, $this->settings[
'compress'], $duration);
138 return $this->memcache->get($key);
147 function delete($key)
149 return $this->memcache->delete($key);
159 return $this->memcache->flush();
169 function connect($host, $port = 11211)
171 if ($this->memcache->getServerStatus($host, $port) === 0) {
172 if ($this->memcache->connect($host, $port)) {