<commit_before><?php
/**
 *
 * @version   1.0
 * @author	<NAME> <<EMAIL>>
 * @license   http://opensource.org/licenses/gpl-license.php GNU Public License
 * @copyright Digiflex Development
 * @package   Cache
 */

class PPI_Cache_Memcached implements PPI_Cache_Interface {

	/**
	 * The memcache(d) driver
	 *
	 * @var Memcache|Memcached
	 */
	protected $_handler;

	/**
	 * If a server has been added. Default is false
	 *
	 * @var bool
	 */
	protected $_serverAdded = false;

	/**
	 * The PPI_Cache_Memcached constructor
	 *
	 * @todo use $this->enabled()
	 * @todo Investigate if we can use memcache(d) or just one (with API usage complying to the interface)
	 * @throws PPI_Exception
	 *
	 */
	function __construct() {
		if(extension_loaded('Memcached')) {
			$this->_handler = new Memcached();
		} elseif(extension_loaded('Memcache')) {
			$this->_handler = new Memcache();
		} else {
			throw new PPI_Exception('Unable to use Memcache. Extension not loaded.');
		}
	}

	function init() {}

	/**
	 * Get a value from cache
	 *
	 * @param string $p_sKey The Key
	 * @return mixed
	 */
	function get($p_sKey) {
		if($this->_serverAdded === false) {
			$this->addServer('localhost');
		}
		return $this->_handler->get($p_sKey);
	}

	/**
	 * Set a value in the cache
	 *
	 * @param string $p_sKey The Key
	 * @param mixed $p_mData The Data
	 * @param integer $p_mTTL The Time To Live
	 * @return boolean
	 */
	function set($p_sKey, $p_mData, $p_mTTL = 0) {
		if($this->_serverAdded === false) {
			$this->addServer('localhost');
		}
		return $this->_handler->set($p_sKey, $p_mData,0, (is_numeric($p_mTTL) ? $p_mTTL : strtotime($p_mTTL)));
	}

	/**<commit_msg>Fixed param count on set()<commit_after><?php
/**
 *
 * @version   1.0
 * @author	<NAME> <<EMAIL>>
 * @license   http://opensource.org/licenses/gpl-license.php GNU Public License
 * @copyright Digiflex Development
 * @package   Cache
 */

class PPI_Cache_Memcached implements PPI_Cache_Interface {

	/**
	 * The memcache(d) driver
	 *
	 * @var Memcache|Memcached
	 */
	protected $_handler;

	/**
	 * If a server has been added. Default is false
	 *
	 * @var bool
	 */
	protected $_serverAdded = false;

	/**
	 * The PPI_Cache_Memcached constructor
	 *
	 * @todo use $this->enabled()
	 * @todo Investigate if we can use memcache(d) or just one (with API usage complying to the interface)
	 * @throws PPI_Exception
	 *
	 */
	function __construct() {
		if(extension_loaded('Memcached')) {
			$this->_handler = new Memcached();
		} elseif(extension_loaded('Memcache')) {
			$this->_handler = new Memcache();
		} else {
			throw new PPI_Exception('Unable to use Memcache. Extension not loaded.');
		}
	}

	function init() {}

	/**
	 * Get a value from cache
	 *
	 * @param string $p_sKey The Key
	 * @return mixed
	 */
	function get($p_sKey) {
		if($this->_serverAdded === false) {
			$this->addServer('localhost');
		}
		return $this->_handler->get($p_sKey);
	}

	/**
	 * Set a value in the cache
	 *
	 * @param string $p_sKey The Key
	 * @param mixed $p_mData The Data
	 * @param integer $p_mTTL The Time To Live
	 * @return boolean
	 */
	function set($p_sKey, $p_mData, $p_mTTL = 0) {
		if($this->_serverAdded === false) {
			$this->addServer('localhost');
		}
		return $this->_handler->set($p_sKey, $p_mData, (is_numeric($p_mTTL) ? $p_mTTL : strtotime($p_mTTL)));
	}

	/**
{'fraction_non_alphanumeric': 0.15100570399279495, 'fraction_numerical': 0.0021014710297208045, 'mean_word_length': 3.4485981308411215, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6025709', 'n_tokens_mistral': 1244, 'n_tokens_neox': 1129, 'n_words': 296}