Merge "Removed executeReadyPeriodicTasks() method"
[lhc/web/wiklou.git] / includes / libs / objectcache / BagOStuff.php
index 150a7ce..5507e9d 100644 (file)
@@ -37,10 +37,10 @@ use Psr\Log\NullLogger;
  * the PHP memcached client.
  *
  * backends for local hash array and SQL table included:
- * <code>
+ * @code
  *   $bag = new HashBagOStuff();
  *   $bag = new SqlBagOStuff(); # connect to db first
- * </code>
+ * @endcode
  *
  * @ingroup Cache
  */
@@ -119,10 +119,11 @@ abstract class BagOStuff implements LoggerAwareInterface {
         * @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
+        * @throws InvalidArgumentException
         */
        public function merge( $key, $callback, $exptime = 0, $attempts = 10 ) {
                if ( !is_callable( $callback ) ) {
-                       throw new Exception( "Got invalid callback." );
+                       throw new InvalidArgumentException( "Got invalid callback." );
                }
 
                return $this->mergeViaLock( $key, $callback, $exptime, $attempts );
@@ -166,6 +167,7 @@ abstract class BagOStuff implements LoggerAwareInterface {
         * @param mixed $value
         * @param int $exptime Either an interval in seconds or a unix timestamp for expiry
         * @return bool Success
+        * @throws Exception
         */
        protected function cas( $casToken, $key, $value, $exptime = 0 ) {
                throw new Exception( "CAS is not implemented in " . __CLASS__ );
@@ -205,7 +207,7 @@ abstract class BagOStuff implements LoggerAwareInterface {
 
        /**
         * @param string $key
-        * @param int $timeout Lock wait timeout [optional]
+        * @param int $timeout Lock wait timeout; 0 for non-blocking [optional]
         * @param int $expiry Lock expiry [optional]
         * @return bool Success
         */
@@ -385,6 +387,24 @@ abstract class BagOStuff implements LoggerAwareInterface {
                $this->lastError = $err;
        }
 
+       /**
+        * Modify a cache update operation array for EventRelayer::notify()
+        *
+        * This is used for relayed writes, e.g. for broadcasting a change
+        * to multiple data-centers. If the array contains a 'val' field
+        * then the command involves setting a key to that value. Note that
+        * for simplicity, 'val' is always a simple scalar value. This method
+        * is used to possibly serialize the value and add any cache-specific
+        * key/values needed for the relayer daemon (e.g. memcached flags).
+        *
+        * @param array $event
+        * @return array
+        * @since 1.26
+        */
+       public function modifySimpleRelayEvent( array $event ) {
+               return $event;
+       }
+
        /**
         * @param string $text
         */