Merge "objectcache: make the BagOStuff::add() operation more atomic for APC"
authorKrinkle <krinklemail@gmail.com>
Fri, 15 Mar 2019 00:56:02 +0000 (00:56 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 15 Mar 2019 00:56:02 +0000 (00:56 +0000)
includes/libs/objectcache/APCBagOStuff.php
includes/libs/objectcache/APCUBagOStuff.php

index 1fedfaf..847a1eb 100644 (file)
@@ -97,6 +97,14 @@ class APCBagOStuff extends BagOStuff {
                return true;
        }
 
+       public function add( $key, $value, $exptime = 0, $flags = 0 ) {
+               return apc_add(
+                       $key . self::KEY_SUFFIX,
+                       $this->setSerialize( $value ),
+                       $exptime
+               );
+       }
+
        protected function setSerialize( $value ) {
                if ( !$this->nativeSerialize && !$this->isInteger( $value ) ) {
                        $value = serialize( $value );
index fb43d4d..d5f1edc 100644 (file)
@@ -55,6 +55,14 @@ class APCUBagOStuff extends APCBagOStuff {
                return true;
        }
 
+       public function add( $key, $value, $exptime = 0, $flags = 0 ) {
+               return apcu_add(
+                       $key . self::KEY_SUFFIX,
+                       $this->setSerialize( $value ),
+                       $exptime
+               );
+       }
+
        public function delete( $key, $flags = 0 ) {
                apcu_delete( $key . self::KEY_SUFFIX );