MediaWiki  REL1_22
APCBagOStuff.php
Go to the documentation of this file.
00001 <?php
00029 class APCBagOStuff extends BagOStuff {
00035     public function get( $key, &$casToken = null ) {
00036         $val = apc_fetch( $key );
00037 
00038         $casToken = $val;
00039 
00040         if ( is_string( $val ) ) {
00041             if ( $this->isInteger( $val ) ) {
00042                 $val = intval( $val );
00043             } else {
00044                 $val = unserialize( $val );
00045             }
00046         }
00047 
00048         return $val;
00049     }
00050 
00057     public function set( $key, $value, $exptime = 0 ) {
00058         if ( !$this->isInteger( $value ) ) {
00059             $value = serialize( $value );
00060         }
00061 
00062         apc_store( $key, $value, $exptime );
00063 
00064         return true;
00065     }
00066 
00074     public function cas( $casToken, $key, $value, $exptime = 0 ) {
00075         // APC's CAS functions only work on integers
00076         throw new MWException( "CAS is not implemented in " . __CLASS__ );
00077     }
00078 
00084     public function delete( $key, $time = 0 ) {
00085         apc_delete( $key );
00086 
00087         return true;
00088     }
00089 
00097     public function merge( $key, closure $callback, $exptime = 0, $attempts = 10 ) {
00098         return $this->mergeViaLock( $key, $callback, $exptime, $attempts );
00099     }
00100 
00101     public function incr( $key, $value = 1 ) {
00102         return apc_inc( $key, $value );
00103     }
00104 
00105     public function decr( $key, $value = 1 ) {
00106         return apc_dec( $key, $value );
00107     }
00108 }