[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/includes/acm/ -> acm_xcache.php (source)

   1  <?php
   2  /**
   3  *
   4  * @package acm
   5  * @version $Id$
   6  * @copyright (c) 2005, 2009 phpBB Group
   7  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
   8  *
   9  */
  10  
  11  /**
  12  * @ignore
  13  */
  14  if (!defined('IN_PHPBB'))
  15  {
  16      exit;
  17  }
  18  
  19  // Include the abstract base
  20  if (!class_exists('acm_memory'))
  21  {
  22      require("{$phpbb_root_path}includes/acm/acm_memory.$phpEx");
  23  }
  24  
  25  /**
  26  * ACM for XCache
  27  * @package acm
  28  *
  29  * To use this module you need ini_get() enabled and the following INI settings configured as follows:
  30  * - xcache.var_size > 0
  31  * - xcache.admin.enable_auth = off (or xcache.admin.user and xcache.admin.password set)
  32  *
  33  */
  34  class acm extends acm_memory
  35  {
  36      var $extension = 'XCache';
  37  
  38  	function acm()
  39      {
  40          parent::acm_memory();
  41  
  42          if (!function_exists('ini_get') || (int) ini_get('xcache.var_size') <= 0)
  43          {
  44              trigger_error('Increase xcache.var_size setting above 0 or enable ini_get() to use this ACM module.', E_USER_ERROR);
  45          }
  46      }
  47  
  48      /**
  49      * Purge cache data
  50      *
  51      * @return null
  52      */
  53  	function purge()
  54      {
  55          // Run before for XCache, if admin functions are disabled it will terminate execution
  56          parent::purge();
  57  
  58          // If the admin authentication is enabled but not set up, this will cause a nasty error.
  59          // Not much we can do about it though.
  60          $n = xcache_count(XC_TYPE_VAR);
  61  
  62          for ($i = 0; $i < $n; $i++)
  63          {
  64              xcache_clear_cache(XC_TYPE_VAR, $i);
  65          }
  66      }
  67  
  68      /**
  69      * Fetch an item from the cache
  70      *
  71      * @access protected
  72      * @param string $var Cache key
  73      * @return mixed Cached data
  74      */
  75  	function _read($var)
  76      {
  77          $result = xcache_get($this->key_prefix . $var);
  78  
  79          return ($result !== null) ? $result : false;
  80      }
  81  
  82      /**
  83      * Store data in the cache
  84      *
  85      * @access protected
  86      * @param string $var Cache key
  87      * @param mixed $data Data to store
  88      * @param int $ttl Time-to-live of cached data
  89      * @return bool True if the operation succeeded
  90      */
  91  	function _write($var, $data, $ttl = 2592000)
  92      {
  93          return xcache_set($this->key_prefix . $var, $data, $ttl);
  94      }
  95  
  96      /**
  97      * Remove an item from the cache
  98      *
  99      * @access protected
 100      * @param string $var Cache key
 101      * @return bool True if the operation succeeded
 102      */
 103  	function _delete($var)
 104      {
 105          return xcache_unset($this->key_prefix . $var);
 106      }
 107  
 108      /**
 109      * Check if a cache var exists
 110      *
 111      * @access protected
 112      * @param string $var Cache key
 113      * @return bool True if it exists, otherwise false
 114      */    
 115  	function _isset($var)
 116      {
 117          return xcache_isset($this->key_prefix . $var);
 118      }
 119  }
 120  
 121  ?>


Generated: Wed Oct 2 15:03:47 2013 Cross-referenced by PHPXref 0.7.1