[ Index ]

PHP Cross Reference of phpBB-3.1.12-deutsch

title

Body

[close]

/phpbb/cache/driver/ -> xcache.php (source)

   1  <?php
   2  /**
   3  *
   4  * This file is part of the phpBB Forum Software package.
   5  *
   6  * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7  * @license GNU General Public License, version 2 (GPL-2.0)
   8  *
   9  * For full copyright and license information, please see
  10  * the docs/CREDITS.txt file.
  11  *
  12  */
  13  
  14  namespace phpbb\cache\driver;
  15  
  16  /**
  17  * ACM for XCache
  18  *
  19  * To use this module you need ini_get() enabled and the following INI settings configured as follows:
  20  * - xcache.var_size > 0
  21  * - xcache.admin.enable_auth = off (or xcache.admin.user and xcache.admin.password set)
  22  *
  23  */
  24  class xcache extends \phpbb\cache\driver\memory
  25  {
  26      var $extension = 'XCache';
  27  
  28  	function __construct()
  29      {
  30          parent::__construct();
  31  
  32          if (!function_exists('ini_get') || (int) ini_get('xcache.var_size') <= 0)
  33          {
  34              trigger_error('Increase xcache.var_size setting above 0 or enable ini_get() to use this ACM module.', E_USER_ERROR);
  35          }
  36      }
  37  
  38      /**
  39      * {@inheritDoc}
  40      */
  41  	function purge()
  42      {
  43          // Run before for XCache, if admin functions are disabled it will terminate execution
  44          parent::purge();
  45  
  46          // If the admin authentication is enabled but not set up, this will cause a nasty error.
  47          // Not much we can do about it though.
  48          $n = xcache_count(XC_TYPE_VAR);
  49  
  50          for ($i = 0; $i < $n; $i++)
  51          {
  52              xcache_clear_cache(XC_TYPE_VAR, $i);
  53          }
  54      }
  55  
  56      /**
  57      * Fetch an item from the cache
  58      *
  59      * @access protected
  60      * @param string $var Cache key
  61      * @return mixed Cached data
  62      */
  63  	function _read($var)
  64      {
  65          $result = xcache_get($this->key_prefix . $var);
  66  
  67          return ($result !== null) ? $result : false;
  68      }
  69  
  70      /**
  71      * Store data in the cache
  72      *
  73      * @access protected
  74      * @param string $var Cache key
  75      * @param mixed $data Data to store
  76      * @param int $ttl Time-to-live of cached data
  77      * @return bool True if the operation succeeded
  78      */
  79  	function _write($var, $data, $ttl = 2592000)
  80      {
  81          return xcache_set($this->key_prefix . $var, $data, $ttl);
  82      }
  83  
  84      /**
  85      * Remove an item from the cache
  86      *
  87      * @access protected
  88      * @param string $var Cache key
  89      * @return bool True if the operation succeeded
  90      */
  91  	function _delete($var)
  92      {
  93          return xcache_unset($this->key_prefix . $var);
  94      }
  95  
  96      /**
  97      * Check if a cache var exists
  98      *
  99      * @access protected
 100      * @param string $var Cache key
 101      * @return bool True if it exists, otherwise false
 102      */
 103  	function _isset($var)
 104      {
 105          return xcache_isset($this->key_prefix . $var);
 106      }
 107  }


Generated: Thu Jan 11 00:25:41 2018 Cross-referenced by PHPXref 0.7.1