Revert r87145, bug 28752: Xcache doesn't work in cli mode. As pointed out on CR,...
[lhc/web/wiklou.git] / includes / objectcache / XCacheBagOStuff.php
1 <?php
2
3 /**
4 * Wrapper for XCache object caching functions; identical interface
5 * to the APC wrapper
6 *
7 * @ingroup Cache
8 */
9 class XCacheBagOStuff extends BagOStuff {
10 /**
11 * Get a value from the XCache object cache
12 *
13 * @param $key String: cache key
14 * @return mixed
15 */
16 public function get( $key ) {
17 $val = xcache_get( $key );
18
19 if ( is_string( $val ) ) {
20 $val = unserialize( $val );
21 }
22
23 return $val;
24 }
25
26 /**
27 * Store a value in the XCache object cache
28 *
29 * @param $key String: cache key
30 * @param $value Mixed: object to store
31 * @param $expire Int: expiration time
32 * @return bool
33 */
34 public function set( $key, $value, $expire = 0 ) {
35 xcache_set( $key, serialize( $value ), $expire );
36 return true;
37 }
38
39 /**
40 * Remove a value from the XCache object cache
41 *
42 * @param $key String: cache key
43 * @param $time Int: not used in this implementation
44 * @return bool
45 */
46 public function delete( $key, $time = 0 ) {
47 xcache_unset( $key );
48 return true;
49 }
50 }
51