[ Index ]

PHP Cross Reference of phpBB-3.1.12-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          eaccelerator_gc();
  48  
  49          set_config('cache_last_gc', time(), true);
  50      }
  51  
  52      /**
  53      * Fetch an item from the cache
  54      *
  55      * @access protected
  56      * @param string $var Cache key
  57      * @return mixed Cached data
  58      */
  59  	function _read($var)
  60      {
  61          $result = eaccelerator_get($this->key_prefix . $var);
  62  
  63          if ($result === null)
  64          {
  65              return false;
  66          }
  67  
  68          // Handle serialized objects
  69          if (is_string($result) && strpos($result, $this->serialize_header . 'O:') === 0)
  70          {
  71              $result = unserialize(substr($result, strlen($this->serialize_header)));
  72          }
  73  
  74          return $result;
  75      }
  76  
  77      /**
  78      * Store data in the cache
  79      *
  80      * @access protected
  81      * @param string $var Cache key
  82      * @param mixed $data Data to store
  83      * @param int $ttl Time-to-live of cached data
  84      * @return bool True if the operation succeeded
  85      */
  86  	function _write($var, $data, $ttl = 2592000)
  87      {
  88          // Serialize objects and make them easy to detect
  89          $data = (is_object($data)) ? $this->serialize_header . serialize($data) : $data;
  90  
  91          return eaccelerator_put($this->key_prefix . $var, $data, $ttl);
  92      }
  93  
  94      /**
  95      * Remove an item from the cache
  96      *
  97      * @access protected
  98      * @param string $var Cache key
  99      * @return bool True if the operation succeeded
 100      */
 101  	function _delete($var)
 102      {
 103          return eaccelerator_rm($this->key_prefix . $var);
 104      }
 105  }


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