[ Index ]

PHP Cross Reference of MyBB 1.8.29

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              return unserialize($data);
  64          }
  65  
  66          return false;
  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          $status = apc_store($this->unique_id."_".$name, serialize($contents));
  79          return $status;
  80      }
  81  
  82      /**
  83       * Delete a cache
  84       *
  85       * @param string $name The name of the cache
  86       * @return boolean True on success, false on failure
  87       */
  88  	function delete($name)
  89      {
  90          return apc_delete($this->unique_id."_".$name);
  91      }
  92  
  93      /**
  94       * Disconnect from the cache
  95       *
  96       * @return bool
  97       */
  98  	function disconnect()
  99      {
 100          return true;
 101      }
 102  
 103      /**
 104       * @param string $name
 105       *
 106       * @return string
 107       */
 108  	function size_of($name='')
 109      {
 110          global $lang;
 111  
 112          return $lang->na;
 113      }
 114  }


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