[ Index ]

PHP Cross Reference of MyBB

title

Body

[close]

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

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


Generated: Tue Oct 8 19:19:50 2013 Cross-referenced by PHPXref 0.7.1