[ Index ] |
PHP Cross Reference of MyBB |
[Summary view] [Print] [Text view]
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: xcache.php 5297 2010-12-28 22:01:14Z Tomm $ 10 */ 11 12 /** 13 * Xcache Cache Handler 14 */ 15 class xcacheCacheHandler 16 { 17 /** 18 * Unique identifier representing this copy of MyBB 19 */ 20 public $unique_id; 21 22 function xcacheCacheHandler($silent=false) 23 { 24 global $mybb; 25 26 if(!function_exists("xcache_get")) 27 { 28 // Check if our DB engine is loaded 29 if(!extension_loaded("XCache")) 30 { 31 // Throw our super awesome cache loading error 32 $mybb->trigger_generic_error("xcache_load_error"); 33 die; 34 } 35 } 36 } 37 38 /** 39 * Connect and initialize this handler. 40 * 41 * @return boolean True if successful, false on failure 42 */ 43 function connect() 44 { 45 global $mybb; 46 47 // Set a unique identifier for all queries in case other forums on this server also use this cache handler 48 $this->unique_id = md5(MYBB_ROOT); 49 50 return true; 51 } 52 53 /** 54 * Retrieve an item from the cache. 55 * 56 * @param string The name of the cache 57 * @param boolean True if we should do a hard refresh 58 * @return mixed Cache data if successful, false if failure 59 */ 60 61 function fetch($name, $hard_refresh=false) 62 { 63 if(!xcache_isset($this->unique_id."_".$name)) 64 { 65 return false; 66 } 67 return xcache_get($this->unique_id."_".$name); 68 } 69 70 /** 71 * Write an item to the cache. 72 * 73 * @param string The name of the cache 74 * @param mixed 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 return xcache_set($this->unique_id."_".$name, $contents); 80 } 81 82 /** 83 * Delete a cache 84 * 85 * @param string The name of the cache 86 * @return boolean True on success, false on failure 87 */ 88 function delete($name) 89 { 90 return xcache_set($this->unique_id."_".$name, "", 1); 91 } 92 93 /** 94 * Disconnect from the cache 95 */ 96 function disconnect() 97 { 98 return true; 99 } 100 101 function size_of($name) 102 { 103 global $lang; 104 105 return $lang->na; 106 } 107 } 108 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Oct 8 19:19:50 2013 | Cross-referenced by PHPXref 0.7.1 |