[ Index ] |
PHP Cross Reference of MyBB 1.8.38 |
[Summary view] [Print] [Text view]
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 * Xcache Cache Handler 13 */ 14 class xcacheCacheHandler 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("xcache_get")) 28 { 29 // Check if our DB engine is loaded 30 if(!extension_loaded("XCache")) 31 { 32 // Throw our super awesome cache loading error 33 $mybb->trigger_generic_error("xcache_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 if(!xcache_isset($this->unique_id."_".$name)) 61 { 62 return false; 63 } 64 return xcache_get($this->unique_id."_".$name); 65 } 66 67 /** 68 * Write an item to the cache. 69 * 70 * @param string $name The name of the cache 71 * @param mixed $contents The data to write to the cache item 72 * @return boolean True on success, false on failure 73 */ 74 function put($name, $contents) 75 { 76 return xcache_set($this->unique_id."_".$name, $contents); 77 } 78 79 /** 80 * Delete a cache 81 * 82 * @param string $name The name of the cache 83 * @return boolean True on success, false on failure 84 */ 85 function delete($name) 86 { 87 return xcache_set($this->unique_id."_".$name, "", 1); 88 } 89 90 /** 91 * Disconnect from the cache 92 * 93 * @return bool 94 */ 95 function disconnect() 96 { 97 return true; 98 } 99 100 /** 101 * @param string $name 102 * 103 * @return string 104 */ 105 function size_of($name='') 106 { 107 global $lang; 108 109 return $lang->na; 110 } 111 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup | Cross-referenced by PHPXref |