<commit_before><?php
/**
 * Cache class for APC
 *
 * @author NHN (<EMAIL>)
 **/
class CacheApc extends CacheBase {
	/**
	 * Default valid time
	 * @var int
	 */
	var $valid_time = 36000;

	/**
	 * Get instance of CacheApc
	 *
	 * @param void $opt Not used
	 * @return CacheApc instance of CacheApc
	 */
	function getInstance($opt=null){
		if(!$GLOBALS['__CacheApc__']) {
			$GLOBALS['__CacheApc__'] = new CacheApc();
		}
		return $GLOBALS['__CacheApc__'];
	}

	/**
	 * Constructor
	 *
	 * @return void
	 */
	function CacheApc(){
	}

	/**
	 * Return whether support or not support cache
	 *
	 * @return bool Return true on support or false on not support
	 */
	function isSupport(){
		return function_exists('apc_add');
	}

	/**
	 * Cache a variable in the data store
	 *
	 * @param string $key Store the variable using this name. $key are cache-unique, so storing a second value with the same $key will overwrite the original value.
	 * @param mixed $buff The variable to store
	 * @param int $valid_time 	Time To Live; store $buff in the cache for ttl seconds.
	 *							After the ttl has passed., the stored variable will be expunged from the cache (on the next request).
	 *							If no ttl is supplied, use the default valid time CacheApc::valid_time.
	 * @return bool Returns true on success or false on failure.
	 */
	function put($key, $buff, $valid_time = 0){
		if($valid_time == 0) $valid_time = $this->valid_time;
		return apc_store(md5(_XE_PATH_.$key), array(time(), $buff), $valid_time);
	}

	/**
	 * Return whether cache is valid or invalid
	 *
	 * @param string $key Cache key
	 * @param int $modified_time 	Unix time of data modified.
	 *								If stored time is older then modified time, the data is invalid.
	 * @return bool Return true on valid or false on invalid.
	 */
	function isValid($key, $modified_time = 0) {
		$_key = md5(_XE_PATH_.$key);
		$obj = apc_fetch($_key, $success);
		if(!$success || !is_array($obj)) return false;
		unset($obj[1]);

		if($modified_time > 0 && $modified_time > $obj[0]) {
			$this->delete($_key);
			return false;
		}
		
		return true;
	}

	/**
	 * Fetch a stored variable from the cache
	 *
	 * @param string $key The $key used to store the value.
	 * @param int $modified_time 	Unix time of data modified.
	 *								If stored time is older then modified time, return false.
	 * @return false|mixed Return false on failure or older then modified time. Return the string associated with the $key on success.
	 */
	function get($key, $modified_time = 0) {
		$_key = md5(_XE_PATH_.$key);
		$obj = apc_fetch($_key, $success);
		if(!$success || !is_array($obj)) return false;

		if($modified_time > 0 && $modified_time > $obj[0]) {
			$this->delete($_key);
			return false;
		}

		return $obj[1];
	}


	/**
	 * Delete variable from the cache
	 *
	 * @param string $key Used to store the value.
	 * @return void
	 */
	function delete($key) {
		return apc_delete($key);
	}

	/**
	 * Truncate all existing variables at the cache
	 *
	 * @return bool Returns true on success or false on failure.
	 */<commit_msg>PHP APC 적용시 글 수정 반영 안되는 현상<commit_after><?php
/**
 * Cache class for APC
 *
 * @author NHN (<EMAIL>)
 **/
class CacheApc extends CacheBase {
	/**
	 * Default valid time
	 * @var int
	 */
	var $valid_time = 36000;

	/**
	 * Get instance of CacheApc
	 *
	 * @param void $opt Not used
	 * @return CacheApc instance of CacheApc
	 */
	function getInstance($opt=null){
		if(!$GLOBALS['__CacheApc__']) {
			$GLOBALS['__CacheApc__'] = new CacheApc();
		}
		return $GLOBALS['__CacheApc__'];
	}

	/**
	 * Constructor
	 *
	 * @return void
	 */
	function CacheApc(){
	}

	/**
	 * Return whether support or not support cache
	 *
	 * @return bool Return true on support or false on not support
	 */
	function isSupport(){
		return function_exists('apc_add');
	}

	/**
	 * Cache a variable in the data store
	 *
	 * @param string $key Store the variable using this name. $key are cache-unique, so storing a second value with the same $key will overwrite the original value.
	 * @param mixed $buff The variable to store
	 * @param int $valid_time 	Time To Live; store $buff in the cache for ttl seconds.
	 *							After the ttl has passed., the stored variable will be expunged from the cache (on the next request).
	 *							If no ttl is supplied, use the default valid time CacheApc::valid_time.
	 * @return bool Returns true on success or false on failure.
	 */
	function put($key, $buff, $valid_time = 0){
		if($valid_time == 0) $valid_time = $this->valid_time;
		return apc_store(md5(_XE_PATH_.$key), array(time(), $buff), $valid_time);
	}

	/**
	 * Return whether cache is valid or invalid
	 *
	 * @param string $key Cache key
	 * @param int $modified_time 	Unix time of data modified.
	 *								If stored time is older then modified time, the data is invalid.
	 * @return bool Return true on valid or false on invalid.
	 */
	function isValid($key, $modified_time = 0) {
		$_key = md5(_XE_PATH_.$key);
		$obj = apc_fetch($_key, $success);
		if(!$success || !is_array($obj)) return false;
		unset($obj[1]);

		if($modified_time > 0 && $modified_time > $obj[0]) {
			$this->delete($key);
			return false;
		}
		
		return true;
	}

	/**
	 * Fetch a stored variable from the cache
	 *
	 * @param string $key The $key used to store the value.
	 * @param int $modified_time 	Unix time of data modified.
	 *								If stored time is older then modified time, return false.
	 * @return false|mixed Return false on failure or older then modified time. Return the string associated with the $key on success.
	 */
	function get($key, $modified_time = 0) {
		$_key = md5(_XE_PATH_.$key);
		$obj = apc_fetch($_key, $success);
		if(!$success || !is_array($obj)) return false;

		if($modified_time > 0 && $modified_time > $obj[0]) {
			$this->delete($key);
			return false;
		}

		return $obj[1];
	}


	/**
	 * Delete variable from the cache
	 *
	 * @param string $key Used to store the value.
	 * @return void
	 */
	function delete($key) {
		$_key = md5(_XE_PATH_ . $key);
		return apc_delete($_key);
	}

	/**
	 * Truncate all existing variables at the cache
	 *
	 * @return bool Returns true on success or false on failure.
	 */
{'fraction_non_alphanumeric': 0.1240473487919572, 'fraction_numerical': 0.005999675693205773, 'mean_word_length': 3.2479338842975207, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, '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': '5915085', 'n_tokens_mistral': 2216, 'n_tokens_neox': 1968, 'n_words': 718}