* changed display function for length to Linker::formatRevisionSize
[mediawiki.git] / includes / objectcache / XCacheBagOStuff.php
blob6561a5f6a5ea8d319e72af5c0828601c9edef49d
1 <?php
3 /**
4 * Wrapper for XCache object caching functions; identical interface
5 * to the APC wrapper
7 * @ingroup Cache
8 */
9 class XCacheBagOStuff extends BagOStuff {
10 /**
11 * Are we operating in CLI mode? Since xcache doesn't work then and they
12 * don't want to change that
13 * @see bug 28752
14 * @var bool
16 private $isCli = false;
18 public function __construct() {
19 $this->isCli = php_sapi_name() == 'cli';
22 /**
23 * Get a value from the XCache object cache
25 * @param $key String: cache key
26 * @return mixed
28 public function get( $key ) {
29 if( $this->isCli ) {
30 return false;
32 $val = xcache_get( $key );
34 if ( is_string( $val ) ) {
35 $val = unserialize( $val );
38 return $val;
41 /**
42 * Store a value in the XCache object cache
44 * @param $key String: cache key
45 * @param $value Mixed: object to store
46 * @param $expire Int: expiration time
47 * @return bool
49 public function set( $key, $value, $expire = 0 ) {
50 if( !$this->isCli ) {
51 xcache_set( $key, serialize( $value ), $expire );
53 return true;
56 /**
57 * Remove a value from the XCache object cache
59 * @param $key String: cache key
60 * @param $time Int: not used in this implementation
61 * @return bool
63 public function delete( $key, $time = 0 ) {
64 if( !$this->isCli ) {
65 xcache_unset( $key );
67 return true;