{"issue":{"state":"open","pull_request":{"diff_url":null,"html_url":null,"patch_url":null},"milestone":null,"user":{"avatar_url":"https://secure.gravatar.com/avatar/2f9627b73e1e5257020c9c7cbcdd6610?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"2f9627b73e1e5257020c9c7cbcdd6610","url":"https://api.github.com/users/bitbucket-import","login":"bitbucket-import","id":991171},"labels":[{"name":"Bitbucket New","color":"DDDDDD","url":"https://api.github.com/repos/EllisLab/CodeIgniter/labels/Bitbucket+New"}],"assignee":null,"updated_at":"2011-10-31T17:18:40Z","closed_at":null,"comments":1,"url":"https://api.github.com/repos/EllisLab/CodeIgniter/issues/45","body":"When I am using Memcached driver of CodeIgniter, i have problem about it's not support for memcache lib on Zend Server.\r\n\r\nThis is patch for Memcached Drivers\r\n\r\n{{{\r\n#!php\r\n\r\n<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');\r\n/**\r\n * CodeIgniter\r\n *\r\n * An open source application development framework for PHP 4.3.2 or newer\r\n *\r\n * @package\t\tCodeIgniter\r\n * @author\t\tExpressionEngine Dev Team\r\n * @copyright\tCopyright (c) 2006 - 2011 EllisLab, Inc.\r\n * @license\t\thttp://codeigniter.com/user_guide/license.html\r\n * @link\t\thttp://codeigniter.com\r\n * @since\t\tVersion 2.0\r\n * @filesource\t\r\n */\r\n\r\n// ------------------------------------------------------------------------\r\n\r\n/**\r\n * CodeIgniter Memcached Caching Class \r\n *\r\n * @package\t\tCodeIgniter\r\n * @subpackage\tLibraries\r\n * @category\tCore\r\n * @author\t\tExpressionEngine Dev Team\r\n * @link\t\t\r\n */\r\n\r\nclass CI_Cache_memcached extends CI_Driver {\r\n\r\n\tprivate $_memcached;\t// Holds the memcached object\r\n\r\n\tprotected $_memcache_conf \t= array(\r\n\t\t\t\t\t'default' => array(\r\n\t\t\t\t\t\t'host'\t\t=> '127.0.0.1',\r\n\t\t\t\t\t\t'port'\t\t=> 11211,\r\n\t\t\t\t\t\t'weight'\t=> 1\r\n\t\t\t\t\t)\r\n\t\t\t\t);\r\n\r\n\t// ------------------------------------------------------------------------\t\r\n\r\n\t/**\r\n\t * Fetch from cache\r\n\t *\r\n\t * @param \tmixed\t\tunique key id\r\n\t * @return \tmixed\t\tdata on success/false on failure\r\n\t */\t\r\n\tpublic function get($id)\r\n\t{\t\r\n\t\t$data = $this->_memcached->get($id);\r\n\t\t\r\n\t\treturn (is_array($data)) ? $data[0] : FALSE;\r\n\t}\r\n\r\n\t// ------------------------------------------------------------------------\r\n\r\n\t/**\r\n\t * Save\r\n\t *\r\n\t * @param \tstring\t\tunique identifier\r\n\t * @param \tmixed\t\tdata being cached\r\n\t * @param \tint\t\t\ttime to live\r\n\t * @return \tboolean \ttrue on success, false on failure\r\n\t */\r\n\tpublic function save($id, $data, $ttl = 60)\r\n\t{\r\n\t\treturn $this->_memcached->add($id, array($data, time(), $ttl), $ttl);\r\n\t}\r\n\r\n\t// ------------------------------------------------------------------------\r\n\t\r\n\t/**\r\n\t * Delete from Cache\r\n\t *\r\n\t * @param \tmixed\t\tkey to be deleted.\r\n\t * @return \tboolean \ttrue on success, false on failure\r\n\t */\r\n\tpublic function delete($id)\r\n\t{\r\n\t\treturn $this->_memcached->delete($id);\r\n\t}\r\n\r\n\t// ------------------------------------------------------------------------\r\n\t\r\n\t/**\r\n\t * Clean the Cache\r\n\t *\r\n\t * @return \tboolean\t\tfalse on failure/true on success\r\n\t */\r\n\tpublic function clean()\r\n\t{\r\n\t\treturn $this->_memcached->flush();\r\n\t}\r\n\r\n\t// ------------------------------------------------------------------------\r\n\r\n\t/**\r\n\t * Cache Info\r\n\t *\r\n\t * @param \tnull\t\ttype not supported in memcached\r\n\t * @return \tmixed \t\tarray on success, false on failure\r\n\t */\r\n\tpublic function cache_info($type = NULL)\r\n\t{\r\n\t\treturn $this->_memcached->getStats();\r\n\t}\r\n\r\n\t// ------------------------------------------------------------------------\r\n\t\r\n\t/**\r\n\t * Get Cache Metadata\r\n\t *\r\n\t * @param \tmixed\t\tkey to get cache metadata on\r\n\t * @return \tmixed\t\tFALSE on failure, array on success.\r\n\t */\r\n\tpublic function get_metadata($id)\r\n\t{\r\n\t\t$stored = $this->_memcached->get($id);\r\n\r\n\t\tif (count($stored) !== 3)\r\n\t\t{\r\n\t\t\treturn FALSE;\r\n\t\t}\r\n\r\n\t\tlist($data, $time, $ttl) = $stored;\r\n\r\n\t\treturn array(\r\n\t\t\t'expire'\t=> $time + $ttl,\r\n\t\t\t'mtime'\t\t=> $time,\r\n\t\t\t'data'\t\t=> $data\r\n\t\t);\r\n\t}\r\n\r\n\t// ------------------------------------------------------------------------\r\n\r\n\t/**\r\n\t * Setup memcached.\r\n\t */\r\n\tprivate function _setup_memcached()\r\n\t{\r\n\t\t// Try to load memcached server info from the config file.\r\n\t\t$CI =& get_instance();\r\n\r\n\t\tif ($CI->config->load('memcached', TRUE, TRUE))\r\n\t\t{\r\n\t\t\tif (is_array($CI->config->config['memcached']))\r\n\t\t\t{\r\n\t\t\t\t$this->_memcache_conf = NULL;\r\n\r\n\t\t\t\tforeach ($CI->config->config['memcached'] as $name => $conf)\r\n\t\t\t\t{\r\n\t\t\t\t\t$this->_memcache_conf[$name] = $conf;\r\n\t\t\t\t}\t\t\t\t\r\n\t\t\t}\t\t\t\r\n\t\t}\r\n\r\n        if(class_exists('Memcached')) {\r\n            $this->_memcached = new Memcached();\r\n        } else if(class_exists('Memcache')) {\r\n            $this->_memcached = new Memcache();\r\n        } else {\r\n            show_error('Can\\'t create Memcached object.');\r\n            return FALSE;\r\n        }\r\n\r\n\t\tforeach ($this->_memcache_conf['memcached'] as $name => $cache_server)\r\n\t\t{\r\n\t\t\tif ( ! array_key_exists('host', $cache_server))\r\n\t\t\t{\r\n\t\t\t\t$cache_server['host'] = $this->_default_options['host'];\r\n\t\t\t}\r\n\t\r\n\t\t\tif ( ! array_key_exists('port', $cache_server))\r\n\t\t\t{\r\n\t\t\t\t$cache_server['port'] = $this->_default_options['port'];\r\n\t\t\t}\r\n\t\r\n\t\t\tif ( ! array_key_exists('weight', $cache_server))\r\n\t\t\t{\r\n\t\t\t\t$cache_server['weight'] = $this->_default_options['weight'];\r\n\t\t\t}\r\n            \r\n\t\t\t$this->_memcached->addServer(\r\n\t\t\t\t\t$cache_server['host'], $cache_server['port'], $cache_server['weight']\r\n\t\t\t);\r\n\t\t}\r\n\t}\r\n\r\n\t// ------------------------------------------------------------------------\r\n\r\n\r\n\t/**\r\n\t * Is supported\r\n\t *\r\n\t * Returns FALSE if memcached is not supported on the system.\r\n\t * If it is, we setup the memcached object & return TRUE\r\n\t */\r\n\tpublic function is_supported()\r\n\t{\r\n        \r\n\t\tif ( ! extension_loaded('memcache') && !extension_loaded('memcached'))\r\n\t\t{\r\n\t\t\tlog_message('error', 'The Memcached Extension must be loaded to use Memcached Cache.');\r\n\t\t\t\r\n\t\t\treturn FALSE;\r\n\t\t}\r\n\t\t\r\n\t\t$this->_setup_memcached();\r\n\t\treturn TRUE;\r\n\t}\r\n\r\n\t// ------------------------------------------------------------------------\r\n\r\n}\r\n// End Class\r\n\r\n/* End of file Cache_memcached.php */\r\n/* Location: ./system/libraries/Cache/drivers/Cache_memcached.php */\r\n}}}","html_url":"https://github.com/EllisLab/CodeIgniter/issues/45","number":45,"title":"Update memcached Driver support for Memcache && Memcached ","id":1442027,"created_at":"2011-08-19T14:46:10Z"},"action":"created","comment":{"user":{"avatar_url":"https://secure.gravatar.com/avatar/3523367da8b60bd9cebb237017ef9619?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"3523367da8b60bd9cebb237017ef9619","url":"https://api.github.com/users/italodom","login":"italodom","id":1019872},"updated_at":"2011-10-31T17:18:40Z","url":"https://api.github.com/repos/EllisLab/CodeIgniter/issues/comments/2579967","body":"The method takes as addServer 3rd parameter weight, but the documentation (http://www.php.net/manual/en/memcache.addserver.php), the 3rd parameter is the persistent connection, which I fix you implemented to upgrade in the core?","id":2579967,"created_at":"2011-10-31T17:18:40Z"}}