[ Index ]

PHP Cross Reference of MyBB 1.8.37

title

Body

[close]

/inc/cachehandlers/ -> eaccelerator.php (source)

   1  <?php
   2  /**
   3   * MyBB 1.8
   4   * Copyright 2014 MyBB Group, All Rights Reserved
   5   *
   6   * Website: http://www.mybb.com
   7   * License: http://www.mybb.com/about/license
   8   *
   9   */
  10  
  11  /**
  12   * eAccelerator Cache Handler
  13   */
  14  class eacceleratorCacheHandler implements CacheHandlerInterface
  15  {
  16      /**
  17       * Unique identifier representing this copy of MyBB
  18       *
  19       * @var string
  20       */
  21      public $unique_id;
  22  
  23  	function __construct()
  24      {
  25          global $mybb;
  26  
  27          if(!function_exists("eaccelerator_get"))
  28          {
  29              // Check if our DB engine is loaded
  30              if(!extension_loaded("Eaccelerator"))
  31              {
  32                  // Throw our super awesome cache loading error
  33                  $mybb->trigger_generic_error("eaccelerator_load_error");
  34                  die;
  35              }
  36          }
  37      }
  38  
  39      /**
  40       * Connect and initialize this handler.
  41       *
  42       * @return boolean True if successful, false on failure
  43       */
  44  	function connect()
  45      {
  46          // Set a unique identifier for all queries in case other forums on this server also use this cache handler
  47          $this->unique_id = md5(MYBB_ROOT);
  48  
  49          return true;
  50      }
  51  
  52      /**
  53       * Retrieve an item from the cache.
  54       *
  55       * @param string $name The name of the cache
  56       * @return mixed Cache data if successful, false if failure
  57       */
  58  	function fetch($name)
  59      {
  60          $data = eaccelerator_get($this->unique_id."_".$name);
  61          if($data === false)
  62          {
  63              return false;
  64          }
  65  
  66          // use native_unserialize() over my_unserialize() for performance reasons
  67          return native_unserialize($data);
  68      }
  69  
  70      /**
  71       * Write an item to the cache.
  72       *
  73       * @param string $name The name of the cache
  74       * @param mixed $contents The data to write to the cache item
  75       * @return boolean True on success, false on failure
  76       */
  77  	function put($name, $contents)
  78      {
  79          eaccelerator_lock($this->unique_id."_".$name);
  80          $status = eaccelerator_put($this->unique_id."_".$name, serialize($contents));
  81          eaccelerator_unlock($this->unique_id."_".$name);
  82          return $status;
  83      }
  84  
  85      /**
  86       * Delete a cache
  87       *
  88       * @param string $name The name of the cache
  89       * @return boolean True on success, false on failure
  90       */
  91  	function delete($name)
  92      {
  93          return eaccelerator_rm($this->unique_id."_".$name);
  94      }
  95  
  96      /**
  97       * Disconnect from the cache
  98       *
  99       * @return bool
 100       */
 101  	function disconnect()
 102      {
 103          return true;
 104      }
 105  
 106      /**
 107       * @param string $name
 108       *
 109       * @return string
 110       */
 111  	function size_of($name='')
 112      {
 113          global $lang;
 114  
 115          return $lang->na;
 116      }
 117  }


2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup Cross-referenced by PHPXref