Ejegg has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/349087 )

Change subject: Update libs
......................................................................


Update libs

PHP-Queue to upstream, add psr\cache

Change-Id: I8f491feeae755a6bb14543a75cda452762c39611
---
D coderkungfu/php-queue/.gitreview
M coderkungfu/php-queue/README.md
M coderkungfu/php-queue/composer.json
M coderkungfu/php-queue/demo/queues/BeanstalkSampleQueue.php
M coderkungfu/php-queue/demo/runners/README.md
M coderkungfu/php-queue/src/PHPQueue/Backend/Beanstalkd.php
M coderkungfu/php-queue/src/PHPQueue/Backend/IronMQ.php
M coderkungfu/php-queue/src/PHPQueue/Backend/Memcache.php
M coderkungfu/php-queue/src/PHPQueue/Backend/MongoDB.php
M coderkungfu/php-queue/src/PHPQueue/Backend/PDO.php
M coderkungfu/php-queue/src/PHPQueue/Backend/Predis.php
M coderkungfu/php-queue/src/PHPQueue/Backend/Stomp.php
D coderkungfu/php-queue/src/PHPQueue/Interfaces/IndexedFifoQueueStore.php
D coderkungfu/php-queue/src/PHPQueue/Interfaces/KeyValueStore.php
M coderkungfu/php-queue/test/PHPQueue/Backend/PredisTest.php
D coderkungfu/php-queue/test/PHPQueue/Backend/PredisZsetTest.php
M composer/autoload_psr4.php
M composer/autoload_static.php
M composer/installed.json
A psr/cache/CHANGELOG.md
A psr/cache/LICENSE.txt
A psr/cache/README.md
A psr/cache/composer.json
A psr/cache/src/CacheException.php
A psr/cache/src/CacheItemInterface.php
A psr/cache/src/CacheItemPoolInterface.php
A psr/cache/src/InvalidArgumentException.php
27 files changed, 450 insertions(+), 432 deletions(-)

Approvals:
  Ejegg: Verified; Looks good to me, approved



diff --git a/coderkungfu/php-queue/.gitreview b/coderkungfu/php-queue/.gitreview
deleted file mode 100644
index ffb389a..0000000
--- a/coderkungfu/php-queue/.gitreview
+++ /dev/null
@@ -1,6 +0,0 @@
-[gerrit]
-host=gerrit.wikimedia.org
-port=29418
-project=wikimedia/fundraising/php-queue.git
-defaultbranch=master
-defaultrebase=0
diff --git a/coderkungfu/php-queue/README.md b/coderkungfu/php-queue/README.md
index c69cef1..74ff0e7 100644
--- a/coderkungfu/php-queue/README.md
+++ b/coderkungfu/php-queue/README.md
@@ -1,4 +1,4 @@
-#PHP-Queue#
+# PHP-Queue #
 [![Gitter](https://badges.gitter.im/Join 
Chat.svg)](https://gitter.im/CoderKungfu/php-queue?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
 
 A unified front-end for different queuing backends. Includes a REST server, 
CLI interface and daemon runners.
@@ -190,16 +190,6 @@
 * FifoQueueStore
 
 A first in first out queue accessed by push and pop.
-
-* IndexedFifoQueueStore
-
-Messages are indexed along one column as they are pushed into a FIFO queue,
-otherwise these behave like FifoQueueStore. clear() deletes records by index.
-There is no get() operation, you'll need a KeyValueStore for that.
-
-* KeyValueStore
-
-Jobs can be retrieved and deleted by their index.
 
 ---
 ## License ##
diff --git a/coderkungfu/php-queue/composer.json 
b/coderkungfu/php-queue/composer.json
index f75d7ef..085c069 100644
--- a/coderkungfu/php-queue/composer.json
+++ b/coderkungfu/php-queue/composer.json
@@ -23,21 +23,19 @@
         "clio/clio": "0.1.*"
     },
     "require-dev": {
-        "jakub-onderka/php-parallel-lint": "0.9",
-        "phpunit/phpunit": "4.4.*"
-    },
-    "scripts": {
-        "test": [
-            "parallel-lint . --exclude vendor",
-            "phpunit"
-        ]
+        "mrpoundsign/pheanstalk-5.3": "dev-master",
+        "aws/aws-sdk-php": "dev-master",
+        "amazonwebservices/aws-sdk-for-php": "dev-master",
+        "predis/predis": "1.*",
+        "iron-io/iron_mq": "dev-master",
+        "ext-memcache": "*",
+        "microsoft/windowsazure": "dev-master"
     },
     "suggest": {
         "predis/predis": "For Redis backend support",
         "mrpoundsign/pheanstalk-5.3": "For Beanstalkd backend support",
         "aws/aws-sdk-php": "For AWS SQS backend support",
         "amazonwebservices/aws-sdk-for-php": "For AWS SQS backend support 
(legacy version)",
-        "ext-memcache": "*",
         "pecl-mongodb": "For MongoDB backend support",
         "clio/clio": "Support for daemonizing PHP CLI runner",
         "iron-io/iron_mq": "For IronMQ backend support",
diff --git a/coderkungfu/php-queue/demo/queues/BeanstalkSampleQueue.php 
b/coderkungfu/php-queue/demo/queues/BeanstalkSampleQueue.php
index 158f339..9335e4f 100644
--- a/coderkungfu/php-queue/demo/queues/BeanstalkSampleQueue.php
+++ b/coderkungfu/php-queue/demo/queues/BeanstalkSampleQueue.php
@@ -19,10 +19,10 @@
                         );
     }
 
-    public function addJob($newJob = null)
+    public function addJob($newJob = null, $DEFAULT_PRIORITY=1024, 
$DEFAULT_DELAY=0, $DEFAULT_TTR=60)
     {
         $formatted_data = array('worker'=>$this->queueWorker, 'data'=>$newJob);
-        $this->dataSource->add($formatted_data);
+        $this->dataSource->add($formatted_data, $DEFAULT_PRIORITY, 
$DEFAULT_DELAY, $DEFAULT_TTR);
 
         return true;
     }
diff --git a/coderkungfu/php-queue/demo/runners/README.md 
b/coderkungfu/php-queue/demo/runners/README.md
index 9c91041..5ddab8d 100644
--- a/coderkungfu/php-queue/demo/runners/README.md
+++ b/coderkungfu/php-queue/demo/runners/README.md
@@ -185,7 +185,7 @@
 1. Add this to the top of your script:
 
        ```
-#!/usr/bin/php
+# !/usr/bin/php
 <?php
 #
 # BeanstalkSampleDaemon    Starts the PHP-Queue runner for BeanstalkSample
diff --git a/coderkungfu/php-queue/src/PHPQueue/Backend/Beanstalkd.php 
b/coderkungfu/php-queue/src/PHPQueue/Backend/Beanstalkd.php
index 2d9210f..f763e08 100644
--- a/coderkungfu/php-queue/src/PHPQueue/Backend/Beanstalkd.php
+++ b/coderkungfu/php-queue/src/PHPQueue/Backend/Beanstalkd.php
@@ -3,11 +3,11 @@
 
 use PHPQueue\Exception\BackendException;
 use PHPQueue\Exception\JobNotFoundException;
-use PHPQueue\Interfaces\IndexedFifoQueueStore;
+use PHPQueue\Interfaces\FifoQueueStore;
 
 class Beanstalkd
     extends Base
-    implements IndexedFifoQueueStore
+    implements FifoQueueStore
 {
     public $server_uri;
     public $tube;
@@ -34,9 +34,9 @@
      * @param  array   $data
      * @return boolean Status of saving
      */
-    public function add($data=array())
+    public function add($data=array(), $DEFAULT_PRIORITY=1024, 
$DEFAULT_DELAY=0, $DEFAULT_TTR=60)
     {
-        $this->push($data);
+        $this->push($data, $DEFAULT_PRIORITY, $DEFAULT_DELAY, $DEFAULT_TTR);
         return true;
     }
 
@@ -44,10 +44,10 @@
      * @param array $data
      * @return integer Primary ID of the new record.
      */
-    public function push($data)
+    public function push($data, $DEFAULT_PRIORITY=1024, $DEFAULT_DELAY=0, 
$DEFAULT_TTR=60)
     {
         $this->beforeAdd();
-        $response = 
$this->getConnection()->useTube($this->tube)->put(json_encode($data));
+        $response = 
$this->getConnection()->useTube($this->tube)->put(json_encode($data), 
$DEFAULT_PRIORITY, $DEFAULT_DELAY, $DEFAULT_TTR);
         if (!$response) {
             throw new BackendException("Unable to save job.");
         }
diff --git a/coderkungfu/php-queue/src/PHPQueue/Backend/IronMQ.php 
b/coderkungfu/php-queue/src/PHPQueue/Backend/IronMQ.php
index eb195fd..0cbefd9 100644
--- a/coderkungfu/php-queue/src/PHPQueue/Backend/IronMQ.php
+++ b/coderkungfu/php-queue/src/PHPQueue/Backend/IronMQ.php
@@ -2,11 +2,11 @@
 namespace PHPQueue\Backend;
 
 use PHPQueue\Exception\BackendException;
-use PHPQueue\Interfaces\IndexedFifoQueueStore;
+use PHPQueue\Interfaces\FifoQueueStore;
 
 class IronMQ
     extends Base
-    implements IndexedFifoQueueStore
+    implements FifoQueueStore
 {
     public $token = null;
     public $project_id = null;
diff --git a/coderkungfu/php-queue/src/PHPQueue/Backend/Memcache.php 
b/coderkungfu/php-queue/src/PHPQueue/Backend/Memcache.php
index a210972..b7c03f1 100644
--- a/coderkungfu/php-queue/src/PHPQueue/Backend/Memcache.php
+++ b/coderkungfu/php-queue/src/PHPQueue/Backend/Memcache.php
@@ -2,11 +2,9 @@
 namespace PHPQueue\Backend;
 
 use PHPQueue\Exception\BackendException;
-use PHPQueue\Interfaces\KeyValueStore;
 
 class Memcache
     extends Base
-    implements KeyValueStore
 {
     public $servers;
     public $is_persistent = false;
diff --git a/coderkungfu/php-queue/src/PHPQueue/Backend/MongoDB.php 
b/coderkungfu/php-queue/src/PHPQueue/Backend/MongoDB.php
index 86fc6c1..6a4440f 100644
--- a/coderkungfu/php-queue/src/PHPQueue/Backend/MongoDB.php
+++ b/coderkungfu/php-queue/src/PHPQueue/Backend/MongoDB.php
@@ -5,11 +5,9 @@
 
 use PHPQueue\Exception\BackendException;
 use PHPQueue\Exception\JobNotFoundException;
-use PHPQueue\Interfaces\KeyValueStore;
 
 class MongoDB
     extends Base
-    implements KeyValueStore
 {
     public $server_uri;
     public $db_name;
diff --git a/coderkungfu/php-queue/src/PHPQueue/Backend/PDO.php 
b/coderkungfu/php-queue/src/PHPQueue/Backend/PDO.php
index fe41689..86593b0 100644
--- a/coderkungfu/php-queue/src/PHPQueue/Backend/PDO.php
+++ b/coderkungfu/php-queue/src/PHPQueue/Backend/PDO.php
@@ -4,15 +4,11 @@
 use PHPQueue\Exception\BackendException;
 use PHPQueue\Interfaces\AtomicReadBuffer;
 use PHPQueue\Interfaces\FifoQueueStore;
-use PHPQueue\Interfaces\IndexedFifoQueueStore;
-use PHPQueue\Interfaces\KeyValueStore;
 
 class PDO
     extends Base
     implements AtomicReadBuffer,
-        FifoQueueStore,
-        IndexedFifoQueueStore,
-        KeyValueStore
+        FifoQueueStore
 {
     private $connection_string;
     private $db_user;
diff --git a/coderkungfu/php-queue/src/PHPQueue/Backend/Predis.php 
b/coderkungfu/php-queue/src/PHPQueue/Backend/Predis.php
index aaeb9bd..26e1306 100644
--- a/coderkungfu/php-queue/src/PHPQueue/Backend/Predis.php
+++ b/coderkungfu/php-queue/src/PHPQueue/Backend/Predis.php
@@ -6,34 +6,20 @@
 
 use PHPQueue\Exception\BackendException;
 use PHPQueue\Interfaces\AtomicReadBuffer;
-use PHPQueue\Interfaces\KeyValueStore;
 use PHPQueue\Interfaces\FifoQueueStore;
 use PHPQueue\Json;
 
 /**
- * Wraps several styles of redis use:
- *     - If constructed with a "order_key" option, the data will be accessible
- *       as a key-value store, and will also provide pop and push using
- *       $data[$order_key] as the FIFO ordering.  If the ordering value is a
- *       timestamp, for example, then the queue will have real-world FIFO
- *       behavior over time, and even if the data comes in out of order, we 
will
- *       always pop the true oldest record.
- *       If you wish to push to this type of store, you'll also need to provide
- *       the "correlation_key" option so the random-access key can be
- *       extracted from data.
+ * Wraps redis use:
  *     - Pushing scalar data will store it as a queue under queue_name.
  *     - Setting scalar data will store it under the key.
  *     - If data is an array, setting will store it as a hash, under the key.
- *
- * TODO: The different behaviors should be modeled as several backends which
- * perhaps inherit from an AbstractPredis.
  */
 class Predis
     extends Base
     implements
         AtomicReadBuffer,
-        FifoQueueStore,
-        KeyValueStore
+        FifoQueueStore
 {
     const TYPE_STRING='string';
     const TYPE_HASH='hash';
@@ -41,15 +27,10 @@
     const TYPE_SET='set';
     const TYPE_NONE='none';
 
-    // Internal sub-key to hold the ordering.
-    const FIFO_INDEX = 'fifo';
-
     public $servers;
     public $redis_options = array();
     public $queue_name;
     public $expiry;
-    public $order_key;
-    public $correlation_key;
 
     public function __construct($options=array())
     {
@@ -65,13 +46,6 @@
         }
         if (!empty($options['expiry'])) {
             $this->expiry = $options['expiry'];
-        }
-        if (!empty($options['order_key'])) {
-            $this->order_key = $options['order_key'];
-            $this->redis_options['prefix'] = $this->queue_name . ':';
-        }
-        if (!empty($options['correlation_key'])) {
-            $this->correlation_key = $options['correlation_key'];
         }
     }
 
@@ -100,60 +74,10 @@
             throw new BackendException("No queue specified.");
         }
         $encoded_data = json_encode($data);
-        if ($this->order_key) {
-            if (!$this->correlation_key) {
-                throw new BackendException("Cannot push to indexed fifo queue 
without a correlation key.");
-            }
-            $key = $data[$this->correlation_key];
-            if (!$key) {
-                throw new BackendException("Cannot push to indexed fifo queue 
without correlation data.");
-            }
-            $status = $this->addToIndexedFifoQueue($key, $data);
-            if (!self::boolStatus($status)) {
-                throw new BackendException('Couldn\'t push to indexed fifo 
queue: ' . $status->getMessage());
-            }
-        } else {
-            // Note that we're ignoring the "new length" return value, cos I 
don't
-            // see how to make it useful.
-            $this->getConnection()->rpush($this->queue_name, $encoded_data);
-        }
-    }
 
-    /**
-     * Remove stale elements at the top of the queue and return the first real 
entry
-     *
-     * When data expires, it still leaves a queue entry linking to its
-     * correlation ID.  Clear any of these stale entries at the head of
-     * the queue.
-     *
-     * Note that we run this from inside a transaction, to make it less
-     * likely that we'll hit a race condition.
-     *
-     * @param MultiExec $tx transaction we're working within.
-     *
-     * @return string|null Top element's key, or null if the queue is empty.
-     */
-    public function peekWithCleanup(MultiExec $tx)
-    {
-        for (;;) {
-            // Look up the first element in the FIFO ordering.
-            $values = $tx->zrange(Predis::FIFO_INDEX, 0, 0);
-            if ($values) {
-                // Use that value as a key into the key-value block.
-                $key = $values[0];
-                $exists = $tx->exists($key);
-
-                if (!$exists) {
-                    // If the data is missing, then remove from the FIFO index.
-                    $tx->zrem(Predis::FIFO_INDEX, $key);
-                } else {
-                    return $key;
-                }
-            } else {
-                break;
-            }
-        }
-        return null;
+        // Note that we're ignoring the "new length" return value, cos I don't
+        // see how to make it useful.
+        $this->getConnection()->rpush($this->queue_name, $encoded_data);
     }
 
     /**
@@ -166,33 +90,7 @@
         if (!$this->hasQueue()) {
             throw new BackendException("No queue specified.");
         }
-        if ($this->order_key) {
-            // Pop the first element.
-            // Adapted from 
https://github.com/nrk/predis/blob/v1.0/examples/transaction_using_cas.php
-            $options = array(
-                'cas' => true,
-                'watch' => self::FIFO_INDEX,
-                'retry' => 3,
-            );
-            $self = $this;
-            $this->getConnection()->transaction($options, function ($tx) use 
(&$data, &$self) {
-                // Begin transaction.
-                $tx->multi();
-
-                $key = $self->peekWithCleanup($tx);
-
-                if ($key) {
-                    // Use that value as a key into the key-value block.
-                    $data = $tx->get($key);
-
-                    // Remove from both indexes.
-                    $tx->zrem(Predis::FIFO_INDEX, $key);
-                    $tx->del($key);
-                }
-            });
-        } else {
-            $data = $this->getConnection()->lpop($this->queue_name);
-        }
+        $data = $this->getConnection()->lpop($this->queue_name);
         if (!$data) {
             return null;
         }
@@ -206,9 +104,6 @@
     public function popAtomic($callback) {
         if (!$this->hasQueue()) {
             throw new BackendException("No queue specified.");
-        }
-        if ($this->order_key) {
-            throw new BackendException("atomicPop not yet supported for 
zsets");
         }
 
         // Pop and process the first element, erring on the side of
@@ -246,33 +141,12 @@
         if (!$this->hasQueue()) {
             throw new BackendException("No queue specified.");
         }
-        if ($this->order_key) {
-            // Adapted from 
https://github.com/nrk/predis/blob/v1.0/examples/transaction_using_cas.php
-            $options = array(
-                'cas' => true,
-                'watch' => self::FIFO_INDEX,
-                'retry' => 3,
-            );
-            $self = $this;
-            $this->getConnection()->transaction($options, function ($tx) use 
(&$data, &$self) {
-                // Begin transaction.
-                $tx->multi();
-
-                $key = $self->peekWithCleanup($tx);
-
-                if ($key) {
-                    // Use that value as a key into the key-value block.
-                    $data = $tx->get($key);
-                }
-            });
+        $data_range = $this->getConnection()->lrange($this->queue_name, 0, 0);
+        if (!$data_range) {
+            return null;
         } else {
-            $data_range = $this->getConnection()->lrange($this->queue_name, 0, 
0);
-            if (!$data_range) {
-                return null;
-            } else {
-                // Unpack list.
-                $data = $data_range[0];
-            }
+            // Unpack list.
+            $data = $data_range[0];
         }
         if (!$data) {
             return null;
@@ -323,9 +197,7 @@
         $this->beforeAdd();
         try {
             $status = false;
-            if ($this->order_key) {
-                $status = $this->addToIndexedFifoQueue($key, $data);
-            } elseif (is_array($data)) {
+            if (is_array($data)) {
                 // FIXME: Assert
                 $status = $this->getConnection()->hmset($key, $data);
             } elseif (is_string($data) || is_numeric($data)) {
@@ -341,36 +213,6 @@
         } catch (\Exception $ex) {
             throw new BackendException($ex->getMessage(), $ex->getCode());
         }
-    }
-
-    /**
-     * Store the data under its order and correlation keys
-     *
-     * @param string $key
-     * @param array $data
-     * @return Predis\Response\ResponseInterface
-     */
-    protected function addToIndexedFifoQueue($key, $data)
-    {
-        $options = array(
-            'cas' => true,
-            'watch' => self::FIFO_INDEX,
-            'retry' => 3,
-        );
-        $score = $data[$this->order_key];
-        $encoded_data = json_encode($data);
-        $status = false;
-        $expiry = $this->expiry;
-        $this->getConnection()->transaction($options, function ($tx) use 
($key, $score, $encoded_data, $expiry, &$status) {
-            $tx->multi();
-            $tx->zadd(Predis::FIFO_INDEX, $score, $key);
-            if ($expiry) {
-                $status = $tx->setex($key, $expiry, $encoded_data);
-            } else {
-                $status = $tx->set($key, $encoded_data);
-            }
-        });
-        return $status;
     }
 
     /** @deprecated */
@@ -394,10 +236,6 @@
             return null;
         }
         $this->beforeGet($key);
-        if ($this->order_key) {
-            $data = $this->getConnection()->get($key);
-            return Json::safe_decode($data);
-        }
         $type = $this->getConnection()->type($key);
         switch ($type) {
             case self::TYPE_STRING:
@@ -433,16 +271,7 @@
     {
         $this->beforeClear($key);
 
-        if ($this->order_key) {
-            $result = $this->getConnection()->pipeline()
-                ->zrem(self::FIFO_INDEX, $key)
-                ->del($key)
-                ->execute();
-
-            $num_removed = $result[1];
-        } else {
-            $num_removed = $this->getConnection()->del($key);
-        }
+        $num_removed = $this->getConnection()->del($key);
 
         $this->afterClearRelease();
 
diff --git a/coderkungfu/php-queue/src/PHPQueue/Backend/Stomp.php 
b/coderkungfu/php-queue/src/PHPQueue/Backend/Stomp.php
index e855af3..65bd705 100644
--- a/coderkungfu/php-queue/src/PHPQueue/Backend/Stomp.php
+++ b/coderkungfu/php-queue/src/PHPQueue/Backend/Stomp.php
@@ -7,7 +7,6 @@
 use PHPQueue\Exception\BackendException;
 use PHPQueue\Exception\JobNotFoundException;
 use PHPQueue\Interfaces\FifoQueueStore;
-use PHPQueue\Interfaces\KeyValueStore;
 
 /**
  * Wrap a STOMP queue
@@ -18,7 +17,7 @@
  */
 class Stomp
     extends Base
-    implements FifoQueueStore, KeyValueStore
+    implements FifoQueueStore
 {
     public $queue_name;
     public $uri;
diff --git 
a/coderkungfu/php-queue/src/PHPQueue/Interfaces/IndexedFifoQueueStore.php 
b/coderkungfu/php-queue/src/PHPQueue/Interfaces/IndexedFifoQueueStore.php
deleted file mode 100644
index ff06f66..0000000
--- a/coderkungfu/php-queue/src/PHPQueue/Interfaces/IndexedFifoQueueStore.php
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-namespace PHPQueue\Interfaces;
-
-/**
- * Implemented by backends that provide queue-like access, where each message
- * also has an ID.
- */
-interface IndexedFifoQueueStore extends FifoQueueStore
-{
-    /**
-     * @param mixed $value Serializable value.
-     * @return string Message ID.
-     * @throws \Exception On failure.
-     */
-    public function push($value);
-
-    /**
-     * @return array The next available data.
-     * @throws \PHPQueue\Exception\JobNotFoundException When no data is 
available.
-     * @throws \Exception Other failures.
-     *
-     * @deprecated This is not a safe operation.  Consider using
-     *     AtomicReadBuffer::popAtomic instead.
-     */
-    public function pop();
-
-    /**
-     * @param $key string
-     * @throws \Exception
-     */
-    public function clear($key);
-}
diff --git a/coderkungfu/php-queue/src/PHPQueue/Interfaces/KeyValueStore.php 
b/coderkungfu/php-queue/src/PHPQueue/Interfaces/KeyValueStore.php
deleted file mode 100644
index b9d5823..0000000
--- a/coderkungfu/php-queue/src/PHPQueue/Interfaces/KeyValueStore.php
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-namespace PHPQueue\Interfaces;
-
-/**
- * Implemented by backends that support key-value retrieval.
- */
-interface KeyValueStore
-{
-    /**
-     * @param $key string
-     * @param $value mixed Serializable value
-     * @param $properties array optional additional message properties
-     *     FIXME: Define better.  Are these columns the indexes?  Why separate
-     *     from the message?
-     * @throws \Exception
-     */
-    public function set($key, $value, $properties=array());
-
-    /**
-     * Look up and return a value by its index value.
-     *
-     * @param $key string
-     * @return array The data.
-     * @throws \Exception
-     */
-    public function get($key);
-
-    /**
-     * @param $key string
-     * @throws \Exception
-     */
-    public function clear($key);
-}
diff --git a/coderkungfu/php-queue/test/PHPQueue/Backend/PredisTest.php 
b/coderkungfu/php-queue/test/PHPQueue/Backend/PredisTest.php
index 5eb1527..ed35dfd 100644
--- a/coderkungfu/php-queue/test/PHPQueue/Backend/PredisTest.php
+++ b/coderkungfu/php-queue/test/PHPQueue/Backend/PredisTest.php
@@ -1,5 +1,8 @@
 <?php
 namespace PHPQueue\Backend;
+
+use PHPQueue\Exception\JsonException;
+
 class PredisTest extends \PHPUnit_Framework_TestCase
 {
     private $object;
@@ -188,13 +191,18 @@
         $this->assertNull($this->object->pop());
     }
 
+    /**
+     * @expectedException PHPQueue\Exception\JsonException
+     */
     public function testPopBadJson()
     {
         // Bad JSON
-        $data = "{'a': u'Weezle-'" . mt_rand() . "'}";
+        $data = '{"a": bad "Weezle-' . mt_rand() . '"}';
         $this->object->getConnection()->rpush($this->object->queue_name, 
$data);
 
-        $this->assertNull($this->object->pop());
+        $this->object->pop();
+
+        $this->fail();
     }
 
     public function testPopEmpty()
diff --git a/coderkungfu/php-queue/test/PHPQueue/Backend/PredisZsetTest.php 
b/coderkungfu/php-queue/test/PHPQueue/Backend/PredisZsetTest.php
deleted file mode 100644
index 32df3cb..0000000
--- a/coderkungfu/php-queue/test/PHPQueue/Backend/PredisZsetTest.php
+++ /dev/null
@@ -1,121 +0,0 @@
-<?php
-namespace PHPQueue\Backend;
-class PredisZsetTest extends \PHPUnit_Framework_TestCase
-{
-    private $object;
-
-    public function setUp()
-    {
-        parent::setUp();
-        if (!class_exists('\Predis\Client')) {
-            $this->markTestSkipped('Predis not installed');
-        } else {
-            $options = array(
-                'servers' => array('host' => '127.0.0.1', 'port' => 6379)
-                , 'queue' => 'testqueue-' . mt_rand()
-                , 'order_key' => 'timestamp'
-                , 'correlation_key' => 'txn_id'
-            );
-            $this->object = new Predis($options);
-        }
-    }
-
-    public function tearDown()
-    {
-        if ($this->object) {
-            $this->object->getConnection()->flushall();
-        }
-        parent::tearDown();
-    }
-
-    public function testSet()
-    {
-        $key = 'A0001';
-        $data = array('name' => 'Michael', 'timestamp' => 1);
-        $this->object->set($key, $data);
-
-        $key = 'A0001';
-        $data = array('name' => 'Michael Cheng', 'timestamp' => 2);
-        $this->object->set($key, $data);
-
-        $key = 'A0002';
-        $data = array('name' => 'Michael Cheng', 'timestamp' => 3);
-        $this->object->set($key, $data);
-    }
-
-    public function testGet()
-    {
-        $key = 'A0001';
-        $data1 = array('name' => 'Michael', 'timestamp' => 1);
-        $this->object->set($key, $data1);
-
-        $key = 'A0001';
-        $data2 = array('name' => 'Michael Cheng', 'timestamp' => 2);
-        $this->object->set($key, $data2);
-
-        $key = 'A0002';
-        $data3 = array('name' => 'Michael Cheng', 'timestamp' => 3);
-        $this->object->set($key, $data3);
-
-        $result = $this->object->get('A0001');
-        $this->assertEquals($data2, $result);
-
-        $result = $this->object->getKey('A0002');
-        $this->assertEquals($data3, $result);
-    }
-
-    public function testClear()
-    {
-        $key = 'A0002';
-        $data = array('name' => 'Adam Wight', 'timestamp' => 2718);
-        $result = $this->object->set($key, $data);
-
-        $result = $this->object->clear($key);
-        $this->assertTrue($result);
-
-        $result = $this->object->get($key);
-        $this->assertNull($result);
-    }
-
-    public function testClearEmpty()
-    {
-        $jobId = 'xxx';
-        $this->assertFalse($this->object->clear($jobId));
-    }
-
-    public function testPushPop()
-    {
-        $data = array(
-            'name' => 'Weezle-' . mt_rand(),
-            'timestamp' => mt_rand(),
-            'txn_id' => mt_rand(),
-        );
-        $this->object->push($data);
-
-        $this->assertEquals($data, $this->object->get($data['txn_id']));
-
-        $this->assertEquals($data, $this->object->pop());
-
-        $this->assertNull($this->object->get($data['txn_id']));
-    }
-
-    public function testPopEmpty()
-    {
-        $this->assertNull($this->object->pop());
-    }
-
-    public function testPeek()
-    {
-        $data = array(
-            'name' => 'Weezle-' . mt_rand(),
-            'timestamp' => mt_rand(),
-            'txn_id' => mt_rand(),
-        );
-        $this->object->push($data);
-
-        $this->assertEquals($data, $this->object->peek());
-
-        // Check that we didn't remove the object by peeking.
-        $this->assertEquals($data, $this->object->pop());
-    }
-}
diff --git a/composer/autoload_psr4.php b/composer/autoload_psr4.php
index 5f15068..1ca0b3b 100644
--- a/composer/autoload_psr4.php
+++ b/composer/autoload_psr4.php
@@ -14,6 +14,7 @@
     'Symfony\\Component\\EventDispatcher\\' => array($vendorDir . 
'/symfony/event-dispatcher'),
     'SmashPig\\' => array($baseDir . '/'),
     'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
+    'Psr\\Cache\\' => array($vendorDir . '/psr/cache/src'),
     'Predis\\' => array($vendorDir . '/predis/predis/src'),
     'PayWithAmazon\\' => array($vendorDir . 
'/amzn/login-and-pay-with-amazon-sdk-php/PayWithAmazon'),
     'Monolog\\' => array($vendorDir . '/monolog/monolog/src/Monolog'),
diff --git a/composer/autoload_static.php b/composer/autoload_static.php
index d4cb9a9..1a5b114 100644
--- a/composer/autoload_static.php
+++ b/composer/autoload_static.php
@@ -27,6 +27,7 @@
         'P' => 
         array (
             'Psr\\Log\\' => 8,
+            'Psr\\Cache\\' => 10,
             'Predis\\' => 7,
             'PayWithAmazon\\' => 14,
         ),
@@ -69,6 +70,10 @@
         array (
             0 => __DIR__ . '/..' . '/psr/log/Psr/Log',
         ),
+        'Psr\\Cache\\' => 
+        array (
+            0 => __DIR__ . '/..' . '/psr/cache/src',
+        ),
         'Predis\\' => 
         array (
             0 => __DIR__ . '/..' . '/predis/predis/src',
diff --git a/composer/installed.json b/composer/installed.json
index 4498e0f..ec1c6d0 100644
--- a/composer/installed.json
+++ b/composer/installed.json
@@ -185,8 +185,14 @@
         "version_normalized": "9999999-dev",
         "source": {
             "type": "git",
-            "url": 
"https://gerrit.wikimedia.org/r/p/wikimedia/fundraising/php-queue.git";,
-            "reference": "d56c5bd69dad595f2e00a3e10c851736b1feb57b"
+            "url": "https://github.com/CoderKungfu/php-queue.git";,
+            "reference": "dd8412f105632d31cdd77933ec40a08640752c99"
+        },
+        "dist": {
+            "type": "zip",
+            "url": 
"https://api.github.com/repos/CoderKungfu/php-queue/zipball/dd8412f105632d31cdd77933ec40a08640752c99";,
+            "reference": "dd8412f105632d31cdd77933ec40a08640752c99",
+            "shasum": ""
         },
         "require": {
             "clio/clio": "0.1.*",
@@ -194,15 +200,19 @@
             "php": ">=5.3.0"
         },
         "require-dev": {
-            "jakub-onderka/php-parallel-lint": "0.9",
-            "phpunit/phpunit": "4.4.*"
+            "amazonwebservices/aws-sdk-for-php": "dev-master",
+            "aws/aws-sdk-php": "dev-master",
+            "ext-memcache": "*",
+            "iron-io/iron_mq": "dev-master",
+            "microsoft/windowsazure": "dev-master",
+            "mrpoundsign/pheanstalk-5.3": "dev-master",
+            "predis/predis": "1.*"
         },
         "suggest": {
             "Respect/Rest": "For a REST server to post job data",
             "amazonwebservices/aws-sdk-for-php": "For AWS SQS backend support 
(legacy version)",
             "aws/aws-sdk-php": "For AWS SQS backend support",
             "clio/clio": "Support for daemonizing PHP CLI runner",
-            "ext-memcache": "*",
             "fusesource/stomp-php": "For the STOMP backend",
             "iron-io/iron_mq": "For IronMQ backend support",
             "microsoft/windowsazure": "For Windows Azure Service Bus backend 
support",
@@ -210,7 +220,7 @@
             "pecl-mongodb": "For MongoDB backend support",
             "predis/predis": "For Redis backend support"
         },
-        "time": "2017-01-04 21:01:15",
+        "time": "2017-04-17 14:11:55",
         "type": "library",
         "extra": {
             "branch-alias": {
@@ -223,12 +233,7 @@
                 "PHPQueue": "src/"
             }
         },
-        "scripts": {
-            "test": [
-                "parallel-lint . --exclude vendor",
-                "phpunit"
-            ]
-        },
+        "notification-url": "https://packagist.org/downloads/";,
         "license": [
             "MIT"
         ],
@@ -784,5 +789,53 @@
         ],
         "description": "Symfony Yaml Component",
         "homepage": "https://symfony.com";
+    },
+    {
+        "name": "psr/cache",
+        "version": "1.0.1",
+        "version_normalized": "1.0.1.0",
+        "source": {
+            "type": "git",
+            "url": "https://github.com/php-fig/cache.git";,
+            "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8"
+        },
+        "dist": {
+            "type": "zip",
+            "url": 
"https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8";,
+            "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8",
+            "shasum": ""
+        },
+        "require": {
+            "php": ">=5.3.0"
+        },
+        "time": "2016-08-06 20:24:11",
+        "type": "library",
+        "extra": {
+            "branch-alias": {
+                "dev-master": "1.0.x-dev"
+            }
+        },
+        "installation-source": "dist",
+        "autoload": {
+            "psr-4": {
+                "Psr\\Cache\\": "src/"
+            }
+        },
+        "notification-url": "https://packagist.org/downloads/";,
+        "license": [
+            "MIT"
+        ],
+        "authors": [
+            {
+                "name": "PHP-FIG",
+                "homepage": "http://www.php-fig.org/";
+            }
+        ],
+        "description": "Common interface for caching libraries",
+        "keywords": [
+            "cache",
+            "psr",
+            "psr-6"
+        ]
     }
 ]
diff --git a/psr/cache/CHANGELOG.md b/psr/cache/CHANGELOG.md
new file mode 100644
index 0000000..58ddab0
--- /dev/null
+++ b/psr/cache/CHANGELOG.md
@@ -0,0 +1,16 @@
+# Changelog
+
+All notable changes to this project will be documented in this file, in 
reverse chronological order by release.
+
+## 1.0.1 - 2016-08-06
+
+### Fixed
+
+- Make spacing consistent in phpdoc annotations php-fig/cache#9 - chalasr
+- Fix grammar in phpdoc annotations php-fig/cache#10 - chalasr
+- Be more specific in docblocks that `getItems()` and `deleteItems()` take an 
array of strings (`string[]`) compared to just `array` php-fig/cache#8 - 
GrahamCampbell
+- For `expiresAt()` and `expiresAfter()` in CacheItemInterface fix docblock to 
specify null as a valid parameters as well as an implementation of 
DateTimeInterface php-fig/cache#7 - GrahamCampbell
+
+## 1.0.0 - 2015-12-11
+
+Initial stable release; reflects accepted PSR-6 specification
diff --git a/psr/cache/LICENSE.txt b/psr/cache/LICENSE.txt
new file mode 100644
index 0000000..b1c2c97
--- /dev/null
+++ b/psr/cache/LICENSE.txt
@@ -0,0 +1,19 @@
+Copyright (c) 2015 PHP Framework Interoperability Group
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/psr/cache/README.md b/psr/cache/README.md
new file mode 100644
index 0000000..c8706ce
--- /dev/null
+++ b/psr/cache/README.md
@@ -0,0 +1,9 @@
+PSR Cache
+=========
+
+This repository holds all interfaces defined by
+[PSR-6](http://www.php-fig.org/psr/psr-6/).
+
+Note that this is not a Cache implementation of its own. It is merely an
+interface that describes a Cache implementation. See the specification for 
more 
+details.
diff --git a/psr/cache/composer.json b/psr/cache/composer.json
new file mode 100644
index 0000000..e828fec
--- /dev/null
+++ b/psr/cache/composer.json
@@ -0,0 +1,25 @@
+{
+    "name": "psr/cache",
+    "description": "Common interface for caching libraries",
+    "keywords": ["psr", "psr-6", "cache"],
+    "license": "MIT",
+    "authors": [
+        {
+            "name": "PHP-FIG",
+            "homepage": "http://www.php-fig.org/";
+        }
+    ],
+    "require": {
+        "php": ">=5.3.0"
+    },
+    "autoload": {
+        "psr-4": {
+            "Psr\\Cache\\": "src/"
+        }
+    },
+    "extra": {
+        "branch-alias": {
+            "dev-master": "1.0.x-dev"
+        }
+    }
+}
diff --git a/psr/cache/src/CacheException.php b/psr/cache/src/CacheException.php
new file mode 100644
index 0000000..e27f22f
--- /dev/null
+++ b/psr/cache/src/CacheException.php
@@ -0,0 +1,10 @@
+<?php
+
+namespace Psr\Cache;
+
+/**
+ * Exception interface for all exceptions thrown by an Implementing Library.
+ */
+interface CacheException
+{
+}
diff --git a/psr/cache/src/CacheItemInterface.php 
b/psr/cache/src/CacheItemInterface.php
new file mode 100644
index 0000000..63d05dd
--- /dev/null
+++ b/psr/cache/src/CacheItemInterface.php
@@ -0,0 +1,105 @@
+<?php
+
+namespace Psr\Cache;
+
+/**
+ * CacheItemInterface defines an interface for interacting with objects inside 
a cache.
+ *
+ * Each Item object MUST be associated with a specific key, which can be set
+ * according to the implementing system and is typically passed by the
+ * Cache\CacheItemPoolInterface object.
+ *
+ * The Cache\CacheItemInterface object encapsulates the storage and retrieval 
of
+ * cache items. Each Cache\CacheItemInterface is generated by a
+ * Cache\CacheItemPoolInterface object, which is responsible for any required
+ * setup as well as associating the object with a unique Key.
+ * Cache\CacheItemInterface objects MUST be able to store and retrieve any type
+ * of PHP value defined in the Data section of the specification.
+ *
+ * Calling Libraries MUST NOT instantiate Item objects themselves. They may 
only
+ * be requested from a Pool object via the getItem() method.  Calling Libraries
+ * SHOULD NOT assume that an Item created by one Implementing Library is
+ * compatible with a Pool from another Implementing Library.
+ */
+interface CacheItemInterface
+{
+    /**
+     * Returns the key for the current cache item.
+     *
+     * The key is loaded by the Implementing Library, but should be available 
to
+     * the higher level callers when needed.
+     *
+     * @return string
+     *   The key string for this cache item.
+     */
+    public function getKey();
+
+    /**
+     * Retrieves the value of the item from the cache associated with this 
object's key.
+     *
+     * The value returned must be identical to the value originally stored by 
set().
+     *
+     * If isHit() returns false, this method MUST return null. Note that null
+     * is a legitimate cached value, so the isHit() method SHOULD be used to
+     * differentiate between "null value was found" and "no value was found."
+     *
+     * @return mixed
+     *   The value corresponding to this cache item's key, or null if not 
found.
+     */
+    public function get();
+
+    /**
+     * Confirms if the cache item lookup resulted in a cache hit.
+     *
+     * Note: This method MUST NOT have a race condition between calling isHit()
+     * and calling get().
+     *
+     * @return bool
+     *   True if the request resulted in a cache hit. False otherwise.
+     */
+    public function isHit();
+
+    /**
+     * Sets the value represented by this cache item.
+     *
+     * The $value argument may be any item that can be serialized by PHP,
+     * although the method of serialization is left up to the Implementing
+     * Library.
+     *
+     * @param mixed $value
+     *   The serializable value to be stored.
+     *
+     * @return static
+     *   The invoked object.
+     */
+    public function set($value);
+
+    /**
+     * Sets the expiration time for this cache item.
+     *
+     * @param \DateTimeInterface|null $expiration
+     *   The point in time after which the item MUST be considered expired.
+     *   If null is passed explicitly, a default value MAY be used. If none is 
set,
+     *   the value should be stored permanently or for as long as the
+     *   implementation allows.
+     *
+     * @return static
+     *   The called object.
+     */
+    public function expiresAt($expiration);
+
+    /**
+     * Sets the expiration time for this cache item.
+     *
+     * @param int|\DateInterval|null $time
+     *   The period of time from the present after which the item MUST be 
considered
+     *   expired. An integer parameter is understood to be the time in seconds 
until
+     *   expiration. If null is passed explicitly, a default value MAY be used.
+     *   If none is set, the value should be stored permanently or for as long 
as the
+     *   implementation allows.
+     *
+     * @return static
+     *   The called object.
+     */
+    public function expiresAfter($time);
+}
diff --git a/psr/cache/src/CacheItemPoolInterface.php 
b/psr/cache/src/CacheItemPoolInterface.php
new file mode 100644
index 0000000..0351419
--- /dev/null
+++ b/psr/cache/src/CacheItemPoolInterface.php
@@ -0,0 +1,138 @@
+<?php
+
+namespace Psr\Cache;
+
+/**
+ * CacheItemPoolInterface generates CacheItemInterface objects.
+ *
+ * The primary purpose of Cache\CacheItemPoolInterface is to accept a key from
+ * the Calling Library and return the associated Cache\CacheItemInterface 
object.
+ * It is also the primary point of interaction with the entire cache 
collection.
+ * All configuration and initialization of the Pool is left up to an
+ * Implementing Library.
+ */
+interface CacheItemPoolInterface
+{
+    /**
+     * Returns a Cache Item representing the specified key.
+     *
+     * This method must always return a CacheItemInterface object, even in 
case of
+     * a cache miss. It MUST NOT return null.
+     *
+     * @param string $key
+     *   The key for which to return the corresponding Cache Item.
+     *
+     * @throws InvalidArgumentException
+     *   If the $key string is not a legal value a 
\Psr\Cache\InvalidArgumentException
+     *   MUST be thrown.
+     *
+     * @return CacheItemInterface
+     *   The corresponding Cache Item.
+     */
+    public function getItem($key);
+
+    /**
+     * Returns a traversable set of cache items.
+     *
+     * @param string[] $keys
+     *   An indexed array of keys of items to retrieve.
+     *
+     * @throws InvalidArgumentException
+     *   If any of the keys in $keys are not a legal value a 
\Psr\Cache\InvalidArgumentException
+     *   MUST be thrown.
+     *
+     * @return array|\Traversable
+     *   A traversable collection of Cache Items keyed by the cache keys of
+     *   each item. A Cache item will be returned for each key, even if that
+     *   key is not found. However, if no keys are specified then an empty
+     *   traversable MUST be returned instead.
+     */
+    public function getItems(array $keys = array());
+
+    /**
+     * Confirms if the cache contains specified cache item.
+     *
+     * Note: This method MAY avoid retrieving the cached value for performance 
reasons.
+     * This could result in a race condition with CacheItemInterface::get(). 
To avoid
+     * such situation use CacheItemInterface::isHit() instead.
+     *
+     * @param string $key
+     *   The key for which to check existence.
+     *
+     * @throws InvalidArgumentException
+     *   If the $key string is not a legal value a 
\Psr\Cache\InvalidArgumentException
+     *   MUST be thrown.
+     *
+     * @return bool
+     *   True if item exists in the cache, false otherwise.
+     */
+    public function hasItem($key);
+
+    /**
+     * Deletes all items in the pool.
+     *
+     * @return bool
+     *   True if the pool was successfully cleared. False if there was an 
error.
+     */
+    public function clear();
+
+    /**
+     * Removes the item from the pool.
+     *
+     * @param string $key
+     *   The key to delete.
+     *
+     * @throws InvalidArgumentException
+     *   If the $key string is not a legal value a 
\Psr\Cache\InvalidArgumentException
+     *   MUST be thrown.
+     *
+     * @return bool
+     *   True if the item was successfully removed. False if there was an 
error.
+     */
+    public function deleteItem($key);
+
+    /**
+     * Removes multiple items from the pool.
+     *
+     * @param string[] $keys
+     *   An array of keys that should be removed from the pool.
+
+     * @throws InvalidArgumentException
+     *   If any of the keys in $keys are not a legal value a 
\Psr\Cache\InvalidArgumentException
+     *   MUST be thrown.
+     *
+     * @return bool
+     *   True if the items were successfully removed. False if there was an 
error.
+     */
+    public function deleteItems(array $keys);
+
+    /**
+     * Persists a cache item immediately.
+     *
+     * @param CacheItemInterface $item
+     *   The cache item to save.
+     *
+     * @return bool
+     *   True if the item was successfully persisted. False if there was an 
error.
+     */
+    public function save(CacheItemInterface $item);
+
+    /**
+     * Sets a cache item to be persisted later.
+     *
+     * @param CacheItemInterface $item
+     *   The cache item to save.
+     *
+     * @return bool
+     *   False if the item could not be queued or if a commit was attempted 
and failed. True otherwise.
+     */
+    public function saveDeferred(CacheItemInterface $item);
+
+    /**
+     * Persists any deferred cache items.
+     *
+     * @return bool
+     *   True if all not-yet-saved items were successfully saved or there were 
none. False otherwise.
+     */
+    public function commit();
+}
diff --git a/psr/cache/src/InvalidArgumentException.php 
b/psr/cache/src/InvalidArgumentException.php
new file mode 100644
index 0000000..be7c6fa
--- /dev/null
+++ b/psr/cache/src/InvalidArgumentException.php
@@ -0,0 +1,13 @@
+<?php
+
+namespace Psr\Cache;
+
+/**
+ * Exception interface for invalid cache arguments.
+ *
+ * Any time an invalid argument is passed into a method it must throw an
+ * exception class which implements Psr\Cache\InvalidArgumentException.
+ */
+interface InvalidArgumentException extends CacheException
+{
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/349087
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I8f491feeae755a6bb14543a75cda452762c39611
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/SmashPig/vendor
Gerrit-Branch: master
Gerrit-Owner: Ejegg <eeggles...@wikimedia.org>
Gerrit-Reviewer: Ejegg <eeggles...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to