[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/phpbb/cache/driver/ -> eaccelerator.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 eAccelerator
  18  * @todo Missing locks from destroy() talk with David
  19  */
  20  class eaccelerator extends \phpbb\cache\driver\memory
  21  {
  22      var $extension = 'eaccelerator';
  23      var $function = 'eaccelerator_get';
  24  
  25      var $serialize_header = '#phpbb-serialized#';
  26  
  27      /**
  28      * {@inheritDoc}
  29      */
  30  	function purge()
  31      {
  32          foreach (eaccelerator_list_keys() as $var)
  33          {
  34              // @todo Check why the substr()
  35              // @todo Only unset vars matching $this->key_prefix
  36              eaccelerator_rm(substr($var['name'], 1));
  37          }
  38  
  39          parent::purge();
  40      }
  41  
  42      /**
  43      * {@inheritDoc}
  44      */
  45  	function tidy()
  46      {
  47          global $config;
  48  
  49          eaccelerator_gc();
  50  
  51          $config->set('cache_last_gc', time(), false);
  52      }
  53  
  54      /**
  55      * Fetch an item from the cache
  56      *
  57      * @access protected
  58      * @param string $var Cache key
  59      * @return mixed Cached data
  60      */
  61  	function _read($var)
  62      {
  63          $result = eaccelerator_get($this->key_prefix . $var);
  64  
  65          if ($result === null)
  66          {
  67              return false;
  68          }
  69  
  70          // Handle serialized objects
  71          if (is_string($result) && strpos($result, $this->serialize_header . 'O:') === 0)
  72          {
  73              $result = unserialize(substr($result, strlen($this->serialize_header)));
  74          }
  75  
  76          return $result;
  77      }
  78  
  79      /**
  80      * Store data in the cache
  81      *
  82      * @access protected
  83      * @param string $var Cache key
  84      * @param mixed $data Data to store
  85      * @param int $ttl Time-to-live of cached data
  86      * @return bool True if the operation succeeded
  87      */
  88  	function _write($var, $data, $ttl = 2592000)
  89      {
  90          // Serialize objects and make them easy to detect
  91          $data = (is_object($data)) ? $this->serialize_header . serialize($data) : $data;
  92  
  93          return eaccelerator_put($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 eaccelerator_rm($this->key_prefix . $var);
 106      }
 107  }


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1