Merge "Special:PagesWithProp: Distinguish content from interface"
[lhc/web/wiklou.git] / includes / objectcache / APCBagOStuff.php
index 1a0de21..3fb8083 100644 (file)
 class APCBagOStuff extends BagOStuff {
        /**
         * @param $key string
+        * @param $casToken[optional] int
         * @return mixed
         */
-       public function get( $key ) {
+       public function get( $key, &$casToken = null ) {
                $val = apc_fetch( $key );
 
+               $casToken = $val;
+
                if ( is_string( $val ) ) {
                        if ( $this->isInteger( $val ) ) {
                                $val = intval( $val );
@@ -61,6 +64,18 @@ class APCBagOStuff extends BagOStuff {
                return true;
        }
 
+       /**
+        * @param $casToken mixed
+        * @param $key string
+        * @param $value mixed
+        * @param $exptime int
+        * @return bool
+        */
+       public function cas( $casToken, $key, $value, $exptime = 0 ) {
+               // APC's CAS functions only work on integers
+               throw new MWException( "CAS is not implemented in " . __CLASS__ );
+       }
+
        /**
         * @param $key string
         * @param $time int
@@ -72,6 +87,17 @@ class APCBagOStuff extends BagOStuff {
                return true;
        }
 
+       /**
+        * @param $key string
+        * @param $callback closure Callback method to be executed
+        * @param int $exptime Either an interval in seconds or a unix timestamp for expiry
+        * @param int $attempts The amount of times to attempt a merge in case of failure
+        * @return bool success
+        */
+       public function merge( $key, closure $callback, $exptime = 0, $attempts = 10 ) {
+               return $this->mergeViaLock( $key, $callback, $exptime, $attempts );
+       }
+
        public function incr( $key, $value = 1 ) {
                return apc_inc( $key, $value );
        }
@@ -79,19 +105,4 @@ class APCBagOStuff extends BagOStuff {
        public function decr( $key, $value = 1 ) {
                return apc_dec( $key, $value );
        }
-
-       /**
-        * @return Array
-        */
-       public function keys() {
-               $info = apc_cache_info( 'user' );
-               $list = $info['cache_list'];
-               $keys = array();
-
-               foreach ( $list as $entry ) {
-                       $keys[] = $entry['info'];
-               }
-
-               return $keys;
-       }
 }