Follow-up I0b781c11 (2a55449): use User::getAutomaticGroups().
[lhc/web/wiklou.git] / includes / objectcache / XCacheBagOStuff.php
1 <?php
2 /**
3 * Object caching using XCache.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @ingroup Cache
22 */
23
24 /**
25 * Wrapper for XCache object caching functions; identical interface
26 * to the APC wrapper
27 *
28 * @ingroup Cache
29 */
30 class XCacheBagOStuff extends BagOStuff {
31 /**
32 * Get a value from the XCache object cache
33 *
34 * @param $key String: cache key
35 * @return mixed
36 */
37 public function get( $key ) {
38 $val = xcache_get( $key );
39
40 if ( is_string( $val ) ) {
41 $val = unserialize( $val );
42 }
43
44 return $val;
45 }
46
47 /**
48 * Store a value in the XCache object cache
49 *
50 * @param $key String: cache key
51 * @param $value Mixed: object to store
52 * @param $expire Int: expiration time
53 * @return bool
54 */
55 public function set( $key, $value, $expire = 0 ) {
56 xcache_set( $key, serialize( $value ), $expire );
57 return true;
58 }
59
60 /**
61 * Remove a value from the XCache object cache
62 *
63 * @param $key String: cache key
64 * @param $time Int: not used in this implementation
65 * @return bool
66 */
67 public function delete( $key, $time = 0 ) {
68 xcache_unset( $key );
69 return true;
70 }
71 }
72