Browse Source

Add dedicated server profile for Redis 3.0.

Daniele Alessandri 10 years ago
parent
commit
88da187344

+ 1 - 1
README.md

@@ -20,7 +20,7 @@ on the online [wiki](https://github.com/nrk/predis/wiki).
 
 ## Main features ##
 
-- Wide range of Redis versions supported (from __2.0__ to __2.8__ and __unstable__) using profiles.
+- Wide range of Redis versions supported (from __2.0__ to __3.0__ and __unstable__) using profiles.
 - Clustering via client-side sharding using consistent hashing or custom distributors.
 - Smart support for [redis-cluster](http://redis.io/topics/cluster-spec) (Redis >= 3.0).
 - Support for master-slave replication configurations (write on master, read from slaves).

+ 1 - 0
src/Profile/Factory.php

@@ -28,6 +28,7 @@ final class Factory
         '2.4'     => 'Predis\Profile\RedisVersion240',
         '2.6'     => 'Predis\Profile\RedisVersion260',
         '2.8'     => 'Predis\Profile\RedisVersion280',
+        '3.0'     => 'Predis\Profile\RedisVersion300',
         'default' => 'Predis\Profile\RedisVersion280',
         'dev'     => 'Predis\Profile\RedisUnstable',
     );

+ 1 - 1
src/Profile/RedisUnstable.php

@@ -16,7 +16,7 @@ namespace Predis\Profile;
  *
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class RedisUnstable extends RedisVersion280
+class RedisUnstable extends RedisVersion300
 {
     /**
      * {@inheritdoc}

+ 261 - 0
src/Profile/RedisVersion300.php

@@ -0,0 +1,261 @@
+<?php
+
+/*
+ * This file is part of the Predis package.
+ *
+ * (c) Daniele Alessandri <suppakilla@gmail.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Predis\Profile;
+
+/**
+ * Server profile for Redis 3.0.
+ *
+ * @author Daniele Alessandri <suppakilla@gmail.com>
+ */
+class RedisVersion300 extends RedisProfile
+{
+    /**
+     * {@inheritdoc}
+     */
+    public function getVersion()
+    {
+        return '3.0';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getSupportedCommands()
+    {
+        return array(
+            /* ---------------- Redis 1.2 ---------------- */
+
+            /* commands operating on the key space */
+            'EXISTS'                    => 'Predis\Command\KeyExists',
+            'DEL'                       => 'Predis\Command\KeyDelete',
+            'TYPE'                      => 'Predis\Command\KeyType',
+            'KEYS'                      => 'Predis\Command\KeyKeys',
+            'RANDOMKEY'                 => 'Predis\Command\KeyRandom',
+            'RENAME'                    => 'Predis\Command\KeyRename',
+            'RENAMENX'                  => 'Predis\Command\KeyRenamePreserve',
+            'EXPIRE'                    => 'Predis\Command\KeyExpire',
+            'EXPIREAT'                  => 'Predis\Command\KeyExpireAt',
+            'TTL'                       => 'Predis\Command\KeyTimeToLive',
+            'MOVE'                      => 'Predis\Command\KeyMove',
+            'SORT'                      => 'Predis\Command\KeySort',
+            'DUMP'                      => 'Predis\Command\KeyDump',
+            'RESTORE'                   => 'Predis\Command\KeyRestore',
+
+            /* commands operating on string values */
+            'SET'                       => 'Predis\Command\StringSet',
+            'SETNX'                     => 'Predis\Command\StringSetPreserve',
+            'MSET'                      => 'Predis\Command\StringSetMultiple',
+            'MSETNX'                    => 'Predis\Command\StringSetMultiplePreserve',
+            'GET'                       => 'Predis\Command\StringGet',
+            'MGET'                      => 'Predis\Command\StringGetMultiple',
+            'GETSET'                    => 'Predis\Command\StringGetSet',
+            'INCR'                      => 'Predis\Command\StringIncrement',
+            'INCRBY'                    => 'Predis\Command\StringIncrementBy',
+            'DECR'                      => 'Predis\Command\StringDecrement',
+            'DECRBY'                    => 'Predis\Command\StringDecrementBy',
+
+            /* commands operating on lists */
+            'RPUSH'                     => 'Predis\Command\ListPushTail',
+            'LPUSH'                     => 'Predis\Command\ListPushHead',
+            'LLEN'                      => 'Predis\Command\ListLength',
+            'LRANGE'                    => 'Predis\Command\ListRange',
+            'LTRIM'                     => 'Predis\Command\ListTrim',
+            'LINDEX'                    => 'Predis\Command\ListIndex',
+            'LSET'                      => 'Predis\Command\ListSet',
+            'LREM'                      => 'Predis\Command\ListRemove',
+            'LPOP'                      => 'Predis\Command\ListPopFirst',
+            'RPOP'                      => 'Predis\Command\ListPopLast',
+            'RPOPLPUSH'                 => 'Predis\Command\ListPopLastPushHead',
+
+            /* commands operating on sets */
+            'SADD'                      => 'Predis\Command\SetAdd',
+            'SREM'                      => 'Predis\Command\SetRemove',
+            'SPOP'                      => 'Predis\Command\SetPop',
+            'SMOVE'                     => 'Predis\Command\SetMove',
+            'SCARD'                     => 'Predis\Command\SetCardinality',
+            'SISMEMBER'                 => 'Predis\Command\SetIsMember',
+            'SINTER'                    => 'Predis\Command\SetIntersection',
+            'SINTERSTORE'               => 'Predis\Command\SetIntersectionStore',
+            'SUNION'                    => 'Predis\Command\SetUnion',
+            'SUNIONSTORE'               => 'Predis\Command\SetUnionStore',
+            'SDIFF'                     => 'Predis\Command\SetDifference',
+            'SDIFFSTORE'                => 'Predis\Command\SetDifferenceStore',
+            'SMEMBERS'                  => 'Predis\Command\SetMembers',
+            'SRANDMEMBER'               => 'Predis\Command\SetRandomMember',
+
+            /* commands operating on sorted sets */
+            'ZADD'                      => 'Predis\Command\ZSetAdd',
+            'ZINCRBY'                   => 'Predis\Command\ZSetIncrementBy',
+            'ZREM'                      => 'Predis\Command\ZSetRemove',
+            'ZRANGE'                    => 'Predis\Command\ZSetRange',
+            'ZREVRANGE'                 => 'Predis\Command\ZSetReverseRange',
+            'ZRANGEBYSCORE'             => 'Predis\Command\ZSetRangeByScore',
+            'ZCARD'                     => 'Predis\Command\ZSetCardinality',
+            'ZSCORE'                    => 'Predis\Command\ZSetScore',
+            'ZREMRANGEBYSCORE'          => 'Predis\Command\ZSetRemoveRangeByScore',
+
+            /* connection related commands */
+            'PING'                      => 'Predis\Command\ConnectionPing',
+            'AUTH'                      => 'Predis\Command\ConnectionAuth',
+            'SELECT'                    => 'Predis\Command\ConnectionSelect',
+            'ECHO'                      => 'Predis\Command\ConnectionEcho',
+            'QUIT'                      => 'Predis\Command\ConnectionQuit',
+
+            /* remote server control commands */
+            'INFO'                      => 'Predis\Command\ServerInfoV26x',
+            'SLAVEOF'                   => 'Predis\Command\ServerSlaveOf',
+            'MONITOR'                   => 'Predis\Command\ServerMonitor',
+            'DBSIZE'                    => 'Predis\Command\ServerDatabaseSize',
+            'FLUSHDB'                   => 'Predis\Command\ServerFlushDatabase',
+            'FLUSHALL'                  => 'Predis\Command\ServerFlushAll',
+            'SAVE'                      => 'Predis\Command\ServerSave',
+            'BGSAVE'                    => 'Predis\Command\ServerBackgroundSave',
+            'LASTSAVE'                  => 'Predis\Command\ServerLastSave',
+            'SHUTDOWN'                  => 'Predis\Command\ServerShutdown',
+            'BGREWRITEAOF'              => 'Predis\Command\ServerBackgroundRewriteAOF',
+
+            /* ---------------- Redis 2.0 ---------------- */
+
+            /* commands operating on string values */
+            'SETEX'                     => 'Predis\Command\StringSetExpire',
+            'APPEND'                    => 'Predis\Command\StringAppend',
+            'SUBSTR'                    => 'Predis\Command\StringSubstr',
+
+            /* commands operating on lists */
+            'BLPOP'                     => 'Predis\Command\ListPopFirstBlocking',
+            'BRPOP'                     => 'Predis\Command\ListPopLastBlocking',
+
+            /* commands operating on sorted sets */
+            'ZUNIONSTORE'               => 'Predis\Command\ZSetUnionStore',
+            'ZINTERSTORE'               => 'Predis\Command\ZSetIntersectionStore',
+            'ZCOUNT'                    => 'Predis\Command\ZSetCount',
+            'ZRANK'                     => 'Predis\Command\ZSetRank',
+            'ZREVRANK'                  => 'Predis\Command\ZSetReverseRank',
+            'ZREMRANGEBYRANK'           => 'Predis\Command\ZSetRemoveRangeByRank',
+
+            /* commands operating on hashes */
+            'HSET'                      => 'Predis\Command\HashSet',
+            'HSETNX'                    => 'Predis\Command\HashSetPreserve',
+            'HMSET'                     => 'Predis\Command\HashSetMultiple',
+            'HINCRBY'                   => 'Predis\Command\HashIncrementBy',
+            'HGET'                      => 'Predis\Command\HashGet',
+            'HMGET'                     => 'Predis\Command\HashGetMultiple',
+            'HDEL'                      => 'Predis\Command\HashDelete',
+            'HEXISTS'                   => 'Predis\Command\HashExists',
+            'HLEN'                      => 'Predis\Command\HashLength',
+            'HKEYS'                     => 'Predis\Command\HashKeys',
+            'HVALS'                     => 'Predis\Command\HashValues',
+            'HGETALL'                   => 'Predis\Command\HashGetAll',
+
+            /* transactions */
+            'MULTI'                     => 'Predis\Command\TransactionMulti',
+            'EXEC'                      => 'Predis\Command\TransactionExec',
+            'DISCARD'                   => 'Predis\Command\TransactionDiscard',
+
+            /* publish - subscribe */
+            'SUBSCRIBE'                 => 'Predis\Command\PubSubSubscribe',
+            'UNSUBSCRIBE'               => 'Predis\Command\PubSubUnsubscribe',
+            'PSUBSCRIBE'                => 'Predis\Command\PubSubSubscribeByPattern',
+            'PUNSUBSCRIBE'              => 'Predis\Command\PubSubUnsubscribeByPattern',
+            'PUBLISH'                   => 'Predis\Command\PubSubPublish',
+
+            /* remote server control commands */
+            'CONFIG'                    => 'Predis\Command\ServerConfig',
+
+            /* ---------------- Redis 2.2 ---------------- */
+
+            /* commands operating on the key space */
+            'PERSIST'                   => 'Predis\Command\KeyPersist',
+
+            /* commands operating on string values */
+            'STRLEN'                    => 'Predis\Command\StringStrlen',
+            'SETRANGE'                  => 'Predis\Command\StringSetRange',
+            'GETRANGE'                  => 'Predis\Command\StringGetRange',
+            'SETBIT'                    => 'Predis\Command\StringSetBit',
+            'GETBIT'                    => 'Predis\Command\StringGetBit',
+
+            /* commands operating on lists */
+            'RPUSHX'                    => 'Predis\Command\ListPushTailX',
+            'LPUSHX'                    => 'Predis\Command\ListPushHeadX',
+            'LINSERT'                   => 'Predis\Command\ListInsert',
+            'BRPOPLPUSH'                => 'Predis\Command\ListPopLastPushHeadBlocking',
+
+            /* commands operating on sorted sets */
+            'ZREVRANGEBYSCORE'          => 'Predis\Command\ZSetReverseRangeByScore',
+
+            /* transactions */
+            'WATCH'                     => 'Predis\Command\TransactionWatch',
+            'UNWATCH'                   => 'Predis\Command\TransactionUnwatch',
+
+            /* remote server control commands */
+            'OBJECT'                    => 'Predis\Command\ServerObject',
+            'SLOWLOG'                   => 'Predis\Command\ServerSlowlog',
+
+            /* ---------------- Redis 2.4 ---------------- */
+
+            /* remote server control commands */
+            'CLIENT'                    => 'Predis\Command\ServerClient',
+
+            /* ---------------- Redis 2.6 ---------------- */
+
+            /* commands operating on the key space */
+            'PTTL'                      => 'Predis\Command\KeyPreciseTimeToLive',
+            'PEXPIRE'                   => 'Predis\Command\KeyPreciseExpire',
+            'PEXPIREAT'                 => 'Predis\Command\KeyPreciseExpireAt',
+
+            /* commands operating on string values */
+            'PSETEX'                    => 'Predis\Command\StringPreciseSetExpire',
+            'INCRBYFLOAT'               => 'Predis\Command\StringIncrementByFloat',
+            'BITOP'                     => 'Predis\Command\StringBitOp',
+            'BITCOUNT'                  => 'Predis\Command\StringBitCount',
+
+            /* commands operating on hashes */
+            'HINCRBYFLOAT'              => 'Predis\Command\HashIncrementByFloat',
+
+            /* scripting */
+            'EVAL'                      => 'Predis\Command\ServerEval',
+            'EVALSHA'                   => 'Predis\Command\ServerEvalSHA',
+            'SCRIPT'                    => 'Predis\Command\ServerScript',
+
+            /* remote server control commands */
+            'TIME'                      => 'Predis\Command\ServerTime',
+            'SENTINEL'                  => 'Predis\Command\ServerSentinel',
+
+            /* ---------------- Redis 2.8 ---------------- */
+
+            /* commands operating on the key space */
+            'SCAN'                      => 'Predis\Command\KeyScan',
+
+            /* commands operating on sets */
+            'SSCAN'                     => 'Predis\Command\SetScan',
+
+            /* commands operating on sorted sets */
+            'ZSCAN'                     => 'Predis\Command\ZSetScan',
+            'ZLEXCOUNT'                 => 'Predis\Command\ZSetLexCount',
+            'ZRANGEBYLEX'               => 'Predis\Command\ZSetRangeByLex',
+            'ZREMRANGEBYLEX'            => 'Predis\Command\ZSetRemoveRangeByLex',
+
+            /* commands operating on hashes */
+            'HSCAN'                     => 'Predis\Command\HashScan',
+
+            /* publish - subscribe */
+            'PUBSUB'                    => 'Predis\Command\PubSubPubsub',
+
+            /* commands operating on HyperLogLog */
+            'PFADD'                     => 'Predis\Command\HyperLogLogAdd',
+            'PFCOUNT'                   => 'Predis\Command\HyperLogLogCount',
+            'PFMERGE'                   => 'Predis\Command\HyperLogLogMerge',
+
+            /* ---------------- Redis 3.0 ---------------- */
+        );
+    }
+}

+ 190 - 0
tests/Predis/Profile/RedisVersion300Test.php

@@ -0,0 +1,190 @@
+<?php
+
+/*
+ * This file is part of the Predis package.
+ *
+ * (c) Daniele Alessandri <suppakilla@gmail.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Predis\Profile;
+
+/**
+ *
+ */
+class RedisVersion300Test extends PredisProfileTestCase
+{
+    /**
+     * {@inheritdoc}
+     */
+    public function getProfile($version = null)
+    {
+        return new RedisVersion300();
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getExpectedVersion()
+    {
+        return '3.0';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getExpectedCommands()
+    {
+        return array(
+            0   => 'EXISTS',
+            1   => 'DEL',
+            2   => 'TYPE',
+            3   => 'KEYS',
+            4   => 'RANDOMKEY',
+            5   => 'RENAME',
+            6   => 'RENAMENX',
+            7   => 'EXPIRE',
+            8   => 'EXPIREAT',
+            9   => 'TTL',
+            10  => 'MOVE',
+            11  => 'SORT',
+            12  => 'DUMP',
+            13  => 'RESTORE',
+            14  => 'SET',
+            15  => 'SETNX',
+            16  => 'MSET',
+            17  => 'MSETNX',
+            18  => 'GET',
+            19  => 'MGET',
+            20  => 'GETSET',
+            21  => 'INCR',
+            22  => 'INCRBY',
+            23  => 'DECR',
+            24  => 'DECRBY',
+            25  => 'RPUSH',
+            26  => 'LPUSH',
+            27  => 'LLEN',
+            28  => 'LRANGE',
+            29  => 'LTRIM',
+            30  => 'LINDEX',
+            31  => 'LSET',
+            32  => 'LREM',
+            33  => 'LPOP',
+            34  => 'RPOP',
+            35  => 'RPOPLPUSH',
+            36  => 'SADD',
+            37  => 'SREM',
+            38  => 'SPOP',
+            39  => 'SMOVE',
+            40  => 'SCARD',
+            41  => 'SISMEMBER',
+            42  => 'SINTER',
+            43  => 'SINTERSTORE',
+            44  => 'SUNION',
+            45  => 'SUNIONSTORE',
+            46  => 'SDIFF',
+            47  => 'SDIFFSTORE',
+            48  => 'SMEMBERS',
+            49  => 'SRANDMEMBER',
+            50  => 'ZADD',
+            51  => 'ZINCRBY',
+            52  => 'ZREM',
+            53  => 'ZRANGE',
+            54  => 'ZREVRANGE',
+            55  => 'ZRANGEBYSCORE',
+            56  => 'ZCARD',
+            57  => 'ZSCORE',
+            58  => 'ZREMRANGEBYSCORE',
+            59  => 'PING',
+            60  => 'AUTH',
+            61  => 'SELECT',
+            62  => 'ECHO',
+            63  => 'QUIT',
+            64  => 'INFO',
+            65  => 'SLAVEOF',
+            66  => 'MONITOR',
+            67  => 'DBSIZE',
+            68  => 'FLUSHDB',
+            69  => 'FLUSHALL',
+            70  => 'SAVE',
+            71  => 'BGSAVE',
+            72  => 'LASTSAVE',
+            73  => 'SHUTDOWN',
+            74  => 'BGREWRITEAOF',
+            75  => 'SETEX',
+            76  => 'APPEND',
+            77  => 'SUBSTR',
+            78  => 'BLPOP',
+            79  => 'BRPOP',
+            80  => 'ZUNIONSTORE',
+            81  => 'ZINTERSTORE',
+            82  => 'ZCOUNT',
+            83  => 'ZRANK',
+            84  => 'ZREVRANK',
+            85  => 'ZREMRANGEBYRANK',
+            86  => 'HSET',
+            87  => 'HSETNX',
+            88  => 'HMSET',
+            89  => 'HINCRBY',
+            90  => 'HGET',
+            91  => 'HMGET',
+            92  => 'HDEL',
+            93  => 'HEXISTS',
+            94  => 'HLEN',
+            95  => 'HKEYS',
+            96  => 'HVALS',
+            97  => 'HGETALL',
+            98  => 'MULTI',
+            99  => 'EXEC',
+            100 => 'DISCARD',
+            101 => 'SUBSCRIBE',
+            102 => 'UNSUBSCRIBE',
+            103 => 'PSUBSCRIBE',
+            104 => 'PUNSUBSCRIBE',
+            105 => 'PUBLISH',
+            106 => 'CONFIG',
+            107 => 'PERSIST',
+            108 => 'STRLEN',
+            109 => 'SETRANGE',
+            110 => 'GETRANGE',
+            111 => 'SETBIT',
+            112 => 'GETBIT',
+            113 => 'RPUSHX',
+            114 => 'LPUSHX',
+            115 => 'LINSERT',
+            116 => 'BRPOPLPUSH',
+            117 => 'ZREVRANGEBYSCORE',
+            118 => 'WATCH',
+            119 => 'UNWATCH',
+            120 => 'OBJECT',
+            121 => 'SLOWLOG',
+            122 => 'CLIENT',
+            123 => 'PTTL',
+            124 => 'PEXPIRE',
+            125 => 'PEXPIREAT',
+            126 => 'PSETEX',
+            127 => 'INCRBYFLOAT',
+            128 => 'BITOP',
+            129 => 'BITCOUNT',
+            130 => 'HINCRBYFLOAT',
+            131 => 'EVAL',
+            132 => 'EVALSHA',
+            133 => 'SCRIPT',
+            134 => 'TIME',
+            135 => 'SENTINEL',
+            136 => 'SCAN',
+            137 => 'SSCAN',
+            138 => 'ZSCAN',
+            139 => 'ZLEXCOUNT',
+            140 => 'ZRANGEBYLEX',
+            141 => 'ZREMRANGEBYLEX',
+            142 => 'HSCAN',
+            143 => 'PUBSUB',
+            144 => 'PFADD',
+            145 => 'PFCOUNT',
+            146 => 'PFMERGE',
+        );
+    }
+}