<commit_before><?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Memcached_library
{
	
	private $config;
	private $local_cache = array();
	private $m;
	private $ci;
	protected $errors = array();
	
	
	public function __construct()
	{
		$this->ci =& get_instance();
		
		$this->m = FALSE;
		if(class_exists('Memcache'))
		{
			$this->ci->load->config('memcached');
			$this->config = $this->ci->config->item('memcached');
			
			$this->m = new Memcache();
			log_message('debug', "Memcached Library: Memcached Class Loaded");
			$this->auto_connect();
		}
	}
	
	/*
	+-------------------------------------+
		Name: auto_connect
		Purpose: runs through all of the servers defined in
		the configuration and attempts to connect to each
		@param return : none
	+-------------------------------------+
	*/
	private function auto_connect()
	{
		foreach($this->config['servers'] as $key=>$server)
		{
			if(!$this->add_server($server))
			{
				$this->errors[] = "Memcached Library: Could not connect to the server named $key";
				log_message('error', 'Memcached Library: Could not connect to the server named "'.$key.'"');
			}
			else
			{
				log_message('debug', 'Memcached Library: Successfully connected to the server named "'.$key.'"');
			}
		}
	}
	
	/*
	+-------------------------------------+
		Name: add_server
		Purpose: 
		@param return : TRUE or FALSE
	+-------------------------------------+
	*/
	public function add_server($server)
	{
		extract($server);
		return $this->m->addServer($host, $port, $persistent, $weight);
	}
	
	/*
	+-------------------------------------+
		Name: add<commit_msg>use the memcached class instead of memcache<commit_after><?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Memcached_library
{
	
	private $config;
	private $local_cache = array();
	private $m;
	private $ci;
	protected $errors = array();
	
	
	public function __construct()
	{
		$this->ci =& get_instance();
		
		$this->m = FALSE;
		if(class_exists('Memcached'))
		{
			$this->ci->load->config('memcached');
			$this->config = $this->ci->config->item('memcached');
			
			$this->m = new Memcached();
			log_message('debug', "Memcached Library: Memcached Class Loaded");
			$this->auto_connect();
		}
	}
	
	/*
	+-------------------------------------+
		Name: auto_connect
		Purpose: runs through all of the servers defined in
		the configuration and attempts to connect to each
		@param return : none
	+-------------------------------------+
	*/
	private function auto_connect()
	{
		foreach($this->config['servers'] as $key=>$server)
		{
			if(!$this->add_server($server))
			{
				$this->errors[] = "Memcached Library: Could not connect to the server named $key";
				log_message('error', 'Memcached Library: Could not connect to the server named "'.$key.'"');
			}
			else
			{
				log_message('debug', 'Memcached Library: Successfully connected to the server named "'.$key.'"');
			}
		}
	}
	
	/*
	+-------------------------------------+
		Name: add_server
		Purpose: 
		@param return : TRUE or FALSE
	+-------------------------------------+
	*/
	public function add_server($server)
	{
		extract($server);
		return $this->m->addServer($host, $port, $weight);
	}
	
	/*
	+-------------------------------------+
		Name: add
{'fraction_non_alphanumeric': 0.2563165905631659, 'fraction_numerical': 0.0, 'mean_word_length': 2.305835010060362, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3494310', 'n_tokens_mistral': 1093, 'n_tokens_neox': 960, 'n_words': 252}