Procházet zdrojové kódy

Promote Redis 2.8 to a standalone server profile.

We still need to populate this new server profile with the
recently added new commands for Redis 2.8.

The next development version has been set to Redis 3.0.
Daniele Alessandri před 11 roky
rodič
revize
d78780382a

+ 1 - 0
lib/Predis/Profile/ServerProfile.php

@@ -77,6 +77,7 @@ abstract class ServerProfile implements ServerProfileInterface, CommandProcessin
             '2.2'     => 'Predis\Profile\ServerVersion22',
             '2.4'     => 'Predis\Profile\ServerVersion24',
             '2.6'     => 'Predis\Profile\ServerVersion26',
+            '2.8'     => 'Predis\Profile\ServerVersion28',
             'default' => 'Predis\Profile\ServerVersion26',
             'dev'     => 'Predis\Profile\ServerVersionNext',
         );

+ 241 - 0
lib/Predis/Profile/ServerVersion28.php

@@ -0,0 +1,241 @@
+<?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 v2.8.x.
+ *
+ * @author Daniele Alessandri <suppakilla@gmail.com>
+ */
+class ServerVersion28 extends ServerProfile
+{
+    /**
+     * {@inheritdoc}
+     */
+    public function getVersion()
+    {
+        return '2.8';
+    }
+
+    /**
+     * {@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\ServerInfo',
+            '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 */
+            'info'                      => 'Predis\Command\ServerInfoV26x',
+            'time'                      => 'Predis\Command\ServerTime',
+
+
+            /* ---------------- Redis 2.8 ---------------- */
+        );
+    }
+}

+ 2 - 2
lib/Predis/Profile/ServerVersionNext.php

@@ -16,14 +16,14 @@ namespace Predis\Profile;
  *
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-class ServerVersionNext extends ServerVersion26
+class ServerVersionNext extends ServerVersion28
 {
     /**
      * {@inheritdoc}
      */
     public function getVersion()
     {
-        return '2.8';
+        return '3.0';
     }
 
     /**

+ 1 - 1
tests/Predis/Profile/ServerProfileTest.php

@@ -21,7 +21,7 @@ use Predis\Command\Processor\ProcessorChain;
 class ServerProfileTest extends StandardTestCase
 {
     const DEFAULT_PROFILE_VERSION = '2.6';
-    const DEVELOPMENT_PROFILE_VERSION = '2.8';
+    const DEVELOPMENT_PROFILE_VERSION = '3.0';
 
     /**
      * @group disconnected

+ 178 - 0
tests/Predis/Profile/ServerVersion28Test.php

@@ -0,0 +1,178 @@
+<?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 ServerVersion28Test extends ServerVersionTestCase
+{
+    /**
+     * {@inheritdoc}
+     */
+    public function getProfileInstance()
+    {
+        return new ServerVersion28();
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getExpectedVersion()
+    {
+        return '2.8';
+    }
+
+    /**
+     * {@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',
+        );
+    }
+}

+ 1 - 1
tests/Predis/Profile/ServerVersionNextTest.php

@@ -29,7 +29,7 @@ class ServerVersionNextTest extends ServerVersionTestCase
      */
     public function getExpectedVersion()
     {
-        return '2.8';
+        return '3.0';
     }
 
     /**