diff options
Diffstat (limited to 'phpBB/includes/acm')
| -rw-r--r-- | phpBB/includes/acm/acm_apc.php | 31 | ||||
| -rw-r--r-- | phpBB/includes/acm/acm_memcache.php | 36 | ||||
| -rw-r--r-- | phpBB/includes/acm/acm_memory.php | 26 | 
3 files changed, 75 insertions, 18 deletions
| diff --git a/phpBB/includes/acm/acm_apc.php b/phpBB/includes/acm/acm_apc.php index 409854bc26..cbda86bec0 100644 --- a/phpBB/includes/acm/acm_apc.php +++ b/phpBB/includes/acm/acm_apc.php @@ -36,6 +36,8 @@ class acm extends acm_memory  	/**  	* Purge cache data +	* +	* @return void  	*/  	function purge()  	{ @@ -44,17 +46,40 @@ class acm extends acm_memory  		parent::purge();  	} -	function read($var) +	/** +	* Fetch an item from the cache +	* +	* @access protected +	* @param string $var Cache key +	* @return mixed Cached data +	*/ +	function _read($var)  	{  		return apc_fetch($var);  	} -	function write($var, $data, $ttl = 2592000) +	/** +	* Store data in the cache +	* +	* @access protected +	* @param string $var Cache key +	* @param mixed $data Data to store +	* @param int $ttl Time-to-live of cached data +	* @return bool True if the operation succeeded +	*/ +	function _write($var, $data, $ttl = 2592000)  	{  		return apc_store($var, $data, $ttl);  	} -	function delete($var) +	/** +	* Remove an item from the cache +	* +	* @access protected +	* @param string $var Cache key +	* @return bool True if the operation succeeded +	*/ +	function _delete($var)  	{  		return apc_delete($var);  	} diff --git a/phpBB/includes/acm/acm_memcache.php b/phpBB/includes/acm/acm_memcache.php index 4950738522..1ec37f1b3b 100644 --- a/phpBB/includes/acm/acm_memcache.php +++ b/phpBB/includes/acm/acm_memcache.php @@ -61,6 +61,11 @@ class acm extends acm_memory  		$this->flags = (PHPBB_ACM_MEMCACHE_COMPRESS) ? MEMCACHE_COMPRESSED : 0;  	} +	/** +	* Unload the cache resources +	* +	* @return void +	*/  	function unload()  	{  		parent::unload(); @@ -70,6 +75,8 @@ class acm extends acm_memory  	/**  	* Purge cache data +	* +	* @return void  	*/  	function purge()  	{ @@ -78,17 +85,40 @@ class acm extends acm_memory  		parent::purge();  	} -	function read($var) +	/** +	* Fetch an item from the cache +	* +	* @access protected +	* @param string $var Cache key +	* @return mixed Cached data +	*/ +	function _read($var)  	{  		return $this->memcache->get($var);  	} -	function write($var, $data, $ttl = 2592000) +	/** +	* Store data in the cache +	* +	* @access protected +	* @param string $var Cache key +	* @param mixed $data Data to store +	* @param int $ttl Time-to-live of cached data +	* @return bool True if the operation succeeded +	*/ +	function _write($var, $data, $ttl = 2592000)  	{  		return $this->memcache->set($var, $data, $this->flags, $ttl);  	} -	function delete($var) +	/** +	* Remove an item from the cache +	* +	* @access protected +	* @param string $var Cache key +	* @return bool True if the operation succeeded +	*/ +	function _delete($var)  	{  		return $this->memcache->delete($var);  	} diff --git a/phpBB/includes/acm/acm_memory.php b/phpBB/includes/acm/acm_memory.php index 964fdb2db4..7875c3441e 100644 --- a/phpBB/includes/acm/acm_memory.php +++ b/phpBB/includes/acm/acm_memory.php @@ -34,6 +34,8 @@ class acm_memory  	*/  	function acm_memory()  	{ +		global $phpbb_root_path; +  		$this->cache_dir = $phpbb_root_path . 'cache/';  	} @@ -43,7 +45,7 @@ class acm_memory  	function load()  	{  		// grab the global cache -		$this->vars = $this->read('global'); +		$this->vars = $this->_read('global');  		if ($this->vars !== false)  		{ @@ -78,7 +80,7 @@ class acm_memory  			return;  		} -		$this->write('global', $this->vars, 2592000); +		$this->_write('global', $this->vars, 2592000);  		$this->is_modified = false;  	} @@ -105,7 +107,7 @@ class acm_memory  				return false;  			} -			return $this->read($var_name); +			return $this->_read($var_name);  		}  		else  		{ @@ -120,7 +122,7 @@ class acm_memory  	{  		if ($var_name[0] == '_')  		{ -			$this->write($var_name, $var, $ttl); +			$this->_write($var_name, $var, $ttl);  		}  		else  		{ @@ -180,7 +182,7 @@ class acm_memory  			foreach ($table as $table_name)  			{  				// gives us the md5s that we want -				$temp = $this->read('sql_' . $table_name); +				$temp = $this->_read('sql_' . $table_name);  				if ($temp === false)  				{ @@ -190,11 +192,11 @@ class acm_memory  				// delete each query ref  				foreach ($temp as $md5_id => $void)  				{ -					$this->delete('sql_' . $md5_id); +					$this->_delete('sql_' . $md5_id);  				}  				// delete the table ref -				$this->delete('sql_' . $table_name); +				$this->_delete('sql_' . $table_name);  			}  			return; @@ -207,7 +209,7 @@ class acm_memory  		if ($var_name[0] == '_')  		{ -			$this->delete($var_name); +			$this->_delete($var_name);  		}  		else if (isset($this->vars[$var_name]))  		{ @@ -248,7 +250,7 @@ class acm_memory  		$query = preg_replace('/[\n\r\s\t]+/', ' ', $query);  		$query_id = sizeof($this->sql_rowset); -		if (($result = $this->read('sql_' . md5($query))) === false) +		if (($result = $this->_read('sql_' . md5($query))) === false)  		{  			return false;  		} @@ -290,7 +292,7 @@ class acm_memory  				$table_name = substr($table_name, 0, $pos);  			} -			$temp = $this->read('sql_' . $table_name); +			$temp = $this->_read('sql_' . $table_name);  			if ($temp === false)  			{ @@ -300,7 +302,7 @@ class acm_memory  			$temp[$hash] = true;  			// This must never expire -			$this->write('sql_' . $table_name, $temp, 0); +			$this->_write('sql_' . $table_name, $temp, 0);  		}  		// store them in the right place @@ -314,7 +316,7 @@ class acm_memory  		}  		$db->sql_freeresult($query_result); -		$this->write('sql_' . $hash, $this->sql_rowset[$query_id], $ttl); +		$this->_write('sql_' . $hash, $this->sql_rowset[$query_id], $ttl);  		$query_result = $query_id;  	} | 
