Переглянути джерело

Add new server profile for Redis 3.2 (new stable).

Daniele Alessandri 8 роки тому
батько
коміт
fcacd65576

+ 1 - 0
src/Profile/Factory.php

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

+ 2 - 5
src/Profile/RedisUnstable.php

@@ -16,7 +16,7 @@ namespace Predis\Profile;
  *
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class RedisUnstable extends RedisVersion300
+class RedisUnstable extends RedisVersion320
 {
     /**
      * {@inheritdoc}
@@ -32,10 +32,7 @@ class RedisUnstable extends RedisVersion300
     public function getSupportedCommands()
     {
         return array_merge(parent::getSupportedCommands(), array(
-            /* ---------------- Redis 3.2 ---------------- */
-
-            /* commands operating on hashes */
-            'HSTRLEN' => 'Predis\Command\HashStringLength',
+            // EMPTY
         ));
     }
 }

+ 272 - 0
src/Profile/RedisVersion320.php

@@ -0,0 +1,272 @@
+<?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 RedisVersion320 extends RedisProfile
+{
+    /**
+     * {@inheritdoc}
+     */
+    public function getVersion()
+    {
+        return '3.2';
+    }
+
+    /**
+     * {@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',
+            'MIGRATE' => 'Predis\Command\KeyMigrate',
+
+            /* 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 string values */
+            'BITPOS' => 'Predis\Command\StringBitPos',
+
+            /* 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',
+            'ZREVRANGEBYLEX' => 'Predis\Command\ZSetReverseRangeByLex',
+
+            /* 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',
+
+            /* remote server control commands */
+            'COMMAND' => 'Predis\Command\ServerCommand',
+
+            /* ---------------- Redis 3.2 ---------------- */
+
+            /* commands operating on hashes */
+            'HSTRLEN' => 'Predis\Command\HashStringLength',
+        );
+    }
+}

+ 195 - 0
tests/Predis/Profile/RedisVersion320Test.php

@@ -0,0 +1,195 @@
+<?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 RedisVersion320Test extends PredisProfileTestCase
+{
+    /**
+     * {@inheritdoc}
+     */
+    public function getProfile($version = null)
+    {
+        return new RedisVersion320();
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getExpectedVersion()
+    {
+        return '3.2';
+    }
+
+    /**
+     * {@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 => 'MIGRATE',
+            127 => 'PSETEX',
+            128 => 'INCRBYFLOAT',
+            129 => 'BITOP',
+            130 => 'BITCOUNT',
+            131 => 'HINCRBYFLOAT',
+            132 => 'EVAL',
+            133 => 'EVALSHA',
+            134 => 'SCRIPT',
+            135 => 'TIME',
+            136 => 'SENTINEL',
+            137 => 'SCAN',
+            138 => 'BITPOS',
+            139 => 'SSCAN',
+            140 => 'ZSCAN',
+            141 => 'ZLEXCOUNT',
+            142 => 'ZRANGEBYLEX',
+            143 => 'ZREMRANGEBYLEX',
+            144 => 'ZREVRANGEBYLEX',
+            145 => 'HSCAN',
+            146 => 'PUBSUB',
+            147 => 'PFADD',
+            148 => 'PFCOUNT',
+            149 => 'PFMERGE',
+            150 => 'COMMAND',
+            151 => 'HSTRLEN',
+        );
+    }
+}