[ Index ]

PHP Cross Reference of MyBB 1.8.37

title

Body

[close]

/inc/cachehandlers/ -> apc.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   * APC Cache Handler
  13   */
  14  class apcCacheHandler 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("apc_fetch"))
  28          {
  29              // Check if our DB engine is loaded
  30              if(!extension_loaded("apc"))
  31              {
  32                  // Throw our super awesome cache loading error
  33                  $mybb->trigger_generic_error("apc_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       * Connect and initialize this handler.
  54       *
  55       * @param string $name
  56       * @return boolean True if successful, false on failure
  57       */
  58  	function fetch($name)
  59      {
  60          if(apc_exists($this->unique_id."_".$name))
  61          {
  62              $data = apc_fetch($this->unique_id."_".$name);
  63  
  64              // use native_unserialize() over my_unserialize() for performance reasons
  65              return native_unserialize($data);
  66          }
  67  
  68          return false;
  69      }
  70  
  71      /**
  72       * Write an item to the cache.
  73       *
  74       * @param string $name The name of the cache
  75       * @param mixed $contents The data to write to the cache item
  76       * @return boolean True on success, false on failure
  77       */
  78  	function put($name, $contents)
  79      {
  80          $status = apc_store($this->unique_id."_".$name, serialize($contents));
  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 apc_delete($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