Index: branches/5.2.x/core/install/install_toolkit.php =================================================================== diff -u -N -r16513 -r16753 --- branches/5.2.x/core/install/install_toolkit.php (.../install_toolkit.php) (revision 16513) +++ branches/5.2.x/core/install/install_toolkit.php (.../install_toolkit.php) (revision 16753) @@ -1,6 +1,6 @@ Application->makeClass('kCache'); $cache_handlers = Array ( - 'Fake' => 'None', 'Memcache' => 'Memcached', 'XCache' => 'XCache', 'Apc' => 'Alternative PHP Cache' + 'Fake' => 'None', + 'Memcached' => 'Memcached (via "Memcached" extension)', + 'Memcache' => 'Memcached (via "Memcache" extension)', + 'XCache' => 'XCache', + 'Apc' => 'Alternative PHP Cache', ); foreach ($cache_handlers AS $class_prefix => $title) { Index: branches/5.2.x/core/kernel/utility/cache.php =================================================================== diff -u -N -r16435 -r16753 --- branches/5.2.x/core/kernel/utility/cache.php (.../cache.php) (revision 16435) +++ branches/5.2.x/core/kernel/utility/cache.php (.../cache.php) (revision 16753) @@ -1,6 +1,6 @@ cachingType = CACHING_TYPE_MEMORY; + + $memcached_servers = kUtil::getSystemConfig()->get('MemcacheServers', $default_servers); + + if ( $memcached_servers && class_exists('Memcached') ) { + $this->_enabled = true; + $this->_handler = new Memcached(); + $servers = explode(';', $memcached_servers); + + foreach ( $servers as $server ) { + if ( preg_match('/(.*):([\d]+)$/', $server, $regs) ) { + // Possible format: "hostname:port" OR "unix:///path/to/socket:0". + $server = $regs[1]; + $port = $regs[2]; + } + else { + $port = 11211; + } + + $this->_handler->addServer($server, $port); + } + + // Verify, that memcache server is working. + if ( !$this->_handler->set('test', 1) ) { + $this->_enabled = false; + } + } + } + + /** + * Retrieves value from cache + * + * @param string|array $name Name. + * + * @return mixed + * @access public + */ + public function get($name) + { + if ( is_array($name) ) { + return $this->_handler->getMulti($name); + } + + return $this->_handler->get($name); + } + + /** + * Stores value in cache + * + * @param string $name Name. + * @param mixed $value Value. + * @param integer $expiration Expiration. + * + * @return boolean + * @access public + */ + public function set($name, $value, $expiration = 0) + { + return $this->_handler->set($name, $value, $expiration); + } + + /** + * Stores value in cache (only if it's not there already) + * + * @param string $name Name. + * @param mixed $value Value. + * @param integer $expiration Expiration. + * + * @return boolean + * @access public + */ + public function add($name, $value, $expiration = 0) + { + return $this->_handler->add($name, $value, $expiration); + } + + /** + * Deletes key from cache + * + * @param string $name Name. + * + * @return boolean + * @access public + */ + public function delete($name) + { + return $this->_handler->delete($name); + } + + } + class ApcCacheHandler extends kCacheHandler { public function __construct(kCache $parent) @@ -974,4 +1084,4 @@ { return xcache_unset($name); } - } \ No newline at end of file + }