MediaWiki  REL1_22
XCacheBagOStuff.php
Go to the documentation of this file.
00001 <?php
00030 class XCacheBagOStuff extends BagOStuff {
00038     public function get( $key, &$casToken = null ) {
00039         $val = xcache_get( $key );
00040 
00041         if ( is_string( $val ) ) {
00042             if ( $this->isInteger( $val ) ) {
00043                 $val = intval( $val );
00044             } else {
00045                 $val = unserialize( $val );
00046             }
00047         } elseif ( is_null( $val ) ) {
00048             return false;
00049         }
00050 
00051         return $val;
00052     }
00053 
00062     public function set( $key, $value, $expire = 0 ) {
00063         if ( !$this->isInteger( $value ) ) {
00064             $value = serialize( $value );
00065         }
00066 
00067         xcache_set( $key, $value, $expire );
00068         return true;
00069     }
00070 
00078     public function cas( $casToken, $key, $value, $exptime = 0 ) {
00079         // Can't find any documentation on xcache cas
00080         throw new MWException( "CAS is not implemented in " . __CLASS__ );
00081     }
00082 
00090     public function delete( $key, $time = 0 ) {
00091         xcache_unset( $key );
00092         return true;
00093     }
00094 
00106     public function merge( $key, closure $callback, $exptime = 0, $attempts = 10 ) {
00107         return $this->mergeViaLock( $key, $callback, $exptime, $attempts );
00108     }
00109 
00110     public function incr( $key, $value = 1 ) {
00111         return xcache_inc( $key, $value );
00112     }
00113 
00114     public function decr( $key, $value = 1 ) {
00115         return xcache_dec( $key, $value );
00116     }
00117 }