3 * Object caching using XCache.
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.
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.
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
25 * Wrapper for XCache object caching functions; identical interface
30 class XCacheBagOStuff
extends BagOStuff
{
32 * Get a value from the XCache object cache
34 * @param string $key Cache key
35 * @param mixed $casToken Cas token
38 public function get( $key, &$casToken = null ) {
39 $val = xcache_get( $key );
41 if ( is_string( $val ) ) {
42 if ( $this->isInteger( $val ) ) {
43 $val = intval( $val );
45 $val = unserialize( $val );
47 } elseif ( is_null( $val ) ) {
55 * Store a value in the XCache object cache
57 * @param string $key Cache key
58 * @param mixed $value Object to store
59 * @param int $expire Expiration time
62 public function set( $key, $value, $expire = 0 ) {
63 if ( !$this->isInteger( $value ) ) {
64 $value = serialize( $value );
67 xcache_set( $key, $value, $expire );
72 * Remove a value from the XCache object cache
74 * @param string $key Cache key
77 public function delete( $key ) {
82 public function incr( $key, $value = 1 ) {
83 return xcache_inc( $key, $value );
86 public function decr( $key, $value = 1 ) {
87 return xcache_dec( $key, $value );