[ Index ]

PHP Cross Reference of MyBB 1.8.29

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          return unserialize($data);
  67      }
  68  
  69      /**
  70       * Write an item to the cache.
  71       *
  72       * @param string $name The name of the cache
  73       * @param mixed $contents The data to write to the cache item
  74       * @return boolean True on success, false on failure
  75       */
  76  	function put($name, $contents)
  77      {
  78          eaccelerator_lock($this->unique_id."_".$name);
  79          $status = eaccelerator_put($this->unique_id."_".$name, serialize($contents));
  80          eaccelerator_unlock($this->unique_id."_".$name);
  81          return $status;
  82      }
  83  
  84      /**
  85       * Delete a cache
  86       *
  87       * @param string $name The name of the cache
  88       * @return boolean True on success, false on failure
  89       */
  90  	function delete($name)
  91      {
  92          return eaccelerator_rm($this->unique_id."_".$name);
  93      }
  94  
  95      /**
  96       * Disconnect from the cache
  97       *
  98       * @return bool
  99       */
 100  	function disconnect()
 101      {
 102          return true;
 103      }
 104  
 105      /**
 106       * @param string $name
 107       *
 108       * @return string
 109       */
 110  	function size_of($name='')
 111      {
 112          global $lang;
 113  
 114          return $lang->na;
 115      }
 116  }


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