includes/acm/acm_wincache.php
author indvdum (gotoindvdum[at]gmail[dot]com)
Thu, 08 Mar 2012 01:33:19 +0400
changeset 11 0a7892c58331
parent 0 ceef6d64c21d
permissions -rw-r--r--
Style fix
     1 <?php
     2 /**
     3 *
     4 * @package acm
     5 * @copyright (c) 2010 phpBB Group
     6 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
     7 *
     8 */
     9 
    10 /**
    11 * @ignore
    12 */
    13 if (!defined('IN_PHPBB'))
    14 {
    15 	exit;
    16 }
    17 
    18 // Include the abstract base
    19 if (!class_exists('acm_memory'))
    20 {
    21 	require("{$phpbb_root_path}includes/acm/acm_memory.$phpEx");
    22 }
    23 
    24 /**
    25 * ACM for WinCache
    26 * @package acm
    27 */
    28 class acm extends acm_memory
    29 {
    30 	var $extension = 'wincache';
    31 
    32 	/**
    33 	* Purge cache data
    34 	*
    35 	* @return void
    36 	*/
    37 	function purge()
    38 	{
    39 		wincache_ucache_clear();
    40 
    41 		parent::purge();
    42 	}
    43 
    44 	/**
    45 	* Fetch an item from the cache
    46 	*
    47 	* @access protected
    48 	* @param string $var Cache key
    49 	* @return mixed Cached data
    50 	*/
    51 	function _read($var)
    52 	{
    53 		$success = false;
    54 		$result = wincache_ucache_get($this->key_prefix . $var, $success);
    55 
    56 		return ($success) ? $result : false;
    57 	}
    58 
    59 	/**
    60 	* Store data in the cache
    61 	*
    62 	* @access protected
    63 	* @param string $var Cache key
    64 	* @param mixed $data Data to store
    65 	* @param int $ttl Time-to-live of cached data
    66 	* @return bool True if the operation succeeded
    67 	*/
    68 	function _write($var, $data, $ttl = 2592000)
    69 	{
    70 		return wincache_ucache_set($this->key_prefix . $var, $data, $ttl);
    71 	}
    72 
    73 	/**
    74 	* Remove an item from the cache
    75 	*
    76 	* @access protected
    77 	* @param string $var Cache key
    78 	* @return bool True if the operation succeeded
    79 	*/
    80 	function _delete($var)
    81 	{
    82 		return wincache_ucache_delete($this->key_prefix . $var);
    83 	}
    84 }