Explorar el Código

Remove support for Redis 1.2.

Actually we have just removed the server profile so nothing stops you
from reimplementing it, but Redis 2.0 has been released 4 years ago so
we are speaking of ancient releases that should probably not even be
used anymore.
Daniele Alessandri hace 10 años
padre
commit
2e0c55ac57

+ 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 __1.2__ to __2.8__ and unstable) using profiles.
+- Wide range of Redis versions supported (from __2.0__ to __2.8__ 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).

+ 0 - 28
lib/Predis/Command/KeyKeysV12x.php

@@ -1,28 +0,0 @@
-<?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\Command;
-
-/**
- * @link http://redis.io/commands/keys
- * @author Daniele Alessandri <suppakilla@gmail.com>
- * @deprecated
- */
-class KeyKeysV12x extends KeyKeys
-{
-    /**
-     * {@inheritdoc}
-     */
-    public function parseResponse($data)
-    {
-        return explode(' ', $data);
-    }
-}

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

@@ -23,7 +23,6 @@ use Predis\ClientException;
 final class Factory
 {
     private static $profiles = array(
-        '1.2'     => 'Predis\Profile\RedisVersion120',
         '2.0'     => 'Predis\Profile\RedisVersion200',
         '2.2'     => 'Predis\Profile\RedisVersion220',
         '2.4'     => 'Predis\Profile\RedisVersion240',

+ 0 - 125
lib/Predis/Profile/RedisVersion120.php

@@ -1,125 +0,0 @@
-<?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 1.2.
- *
- * @author Daniele Alessandri <suppakilla@gmail.com>
- */
-class RedisVersion120 extends RedisProfile
-{
-    /**
-     * {@inheritdoc}
-     */
-    public function getVersion()
-    {
-        return '1.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\KeyKeysV12x',
-            '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',
-
-            /* 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',
-        );
-    }
-}

+ 1 - 1
lib/Predis/Transaction/MultiExec.php

@@ -72,7 +72,7 @@ class MultiExec implements BasicClientInterface, ExecutableContextInterface
             );
         }
 
-        if (!$client->getProfile()->supportsCommands(array('multi', 'exec', 'discard'))) {
+        if (!$client->getProfile()->supportsCommands(array('MULTI', 'EXEC', 'DISCARD'))) {
             throw new NotSupportedException(
                 'The current profile does not support MULTI, EXEC and DISCARD.'
             );

+ 0 - 64
tests/Predis/Command/KeyKeysV12xTest.php

@@ -1,64 +0,0 @@
-<?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\Command;
-
-/**
- * We only perform disconnected tests for this commands because
- * it is too old (Redis v1.2) and expects a different response
- * format.
- *
- * @group commands
- * @group realm-key
- */
-class KeyKeysV12xTest extends PredisCommandTestCase
-{
-    /**
-     * {@inheritdoc}
-     */
-    protected function getExpectedCommand()
-    {
-        return 'Predis\Command\KeyKeysV12x';
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    protected function getExpectedId()
-    {
-        return 'KEYS';
-    }
-
-    /**
-     * @group disconnected
-     */
-    public function testFilterArguments()
-    {
-        $arguments = array('pattern:*');
-        $expected = array('pattern:*');
-
-        $command = $this->getCommand();
-        $command->setArguments($arguments);
-
-        $this->assertSame($expected, $command->getArguments());
-    }
-
-    /**
-     * @group disconnected
-     */
-    public function testParseResponse()
-    {
-        $raw = 'key1 key2 key3';
-        $parsed = array('key1', 'key2', 'key3');
-
-        $this->assertSame($parsed, $this->getCommand()->parseResponse($raw));
-    }
-}

+ 0 - 116
tests/Predis/Profile/RedisVersion120Test.php

@@ -1,116 +0,0 @@
-<?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 RedisVersion120Test extends PredisProfileTestCase
-{
-    /**
-     * {@inheritdoc}
-     */
-    public function getProfile($version = null)
-    {
-        return new RedisVersion120();
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function getExpectedVersion()
-    {
-        return '1.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  => 'SET',
-            13  => 'SETNX',
-            14  => 'MSET',
-            15  => 'MSETNX',
-            16  => 'GET',
-            17  => 'MGET',
-            18  => 'GETSET',
-            19  => 'INCR',
-            20  => 'INCRBY',
-            21  => 'DECR',
-            22  => 'DECRBY',
-            23  => 'RPUSH',
-            24  => 'LPUSH',
-            25  => 'LLEN',
-            26  => 'LRANGE',
-            27  => 'LTRIM',
-            28  => 'LINDEX',
-            29  => 'LSET',
-            30  => 'LREM',
-            31  => 'LPOP',
-            32  => 'RPOP',
-            33  => 'RPOPLPUSH',
-            34  => 'SADD',
-            35  => 'SREM',
-            36  => 'SPOP',
-            37  => 'SMOVE',
-            38  => 'SCARD',
-            39  => 'SISMEMBER',
-            40  => 'SINTER',
-            41  => 'SINTERSTORE',
-            42  => 'SUNION',
-            43  => 'SUNIONSTORE',
-            44  => 'SDIFF',
-            45  => 'SDIFFSTORE',
-            46  => 'SMEMBERS',
-            47  => 'SRANDMEMBER',
-            48  => 'ZADD',
-            49  => 'ZINCRBY',
-            50  => 'ZREM',
-            51  => 'ZRANGE',
-            52  => 'ZREVRANGE',
-            53  => 'ZRANGEBYSCORE',
-            54  => 'ZCARD',
-            55  => 'ZSCORE',
-            56  => 'ZREMRANGEBYSCORE',
-            57  => 'PING',
-            58  => 'AUTH',
-            59  => 'SELECT',
-            60  => 'ECHO',
-            61  => 'QUIT',
-            62  => 'INFO',
-            63  => 'SLAVEOF',
-            64  => 'MONITOR',
-            65  => 'DBSIZE',
-            66  => 'FLUSHDB',
-            67  => 'FLUSHALL',
-            68  => 'SAVE',
-            69  => 'BGSAVE',
-            70  => 'LASTSAVE',
-            71  => 'SHUTDOWN',
-            72  => 'BGREWRITEAOF',
-        );
-    }
-}

+ 32 - 4
tests/Predis/Transaction/MultiExecTest.php

@@ -28,8 +28,15 @@ class MultiExecTest extends PredisTestCase
      */
     public function testThrowsExceptionOnUnsupportedMultiExecInProfile()
     {
+        $profile = $this->getMock('Predis\Profile\ProfileInterface');
+        $profile->expects($this->once())
+                ->method('supportsCommands')
+                ->with(array('MULTI', 'EXEC', 'DISCARD'))
+                ->will($this->returnValue(false));
+
         $connection = $this->getMock('Predis\Connection\NodeConnectionInterface');
-        $client = new Client($connection, array('profile' => '1.2'));
+        $client = new Client($connection, array('profile' => $profile));
+
         $tx = new MultiExec($client);
     }
 
@@ -40,10 +47,20 @@ class MultiExecTest extends PredisTestCase
      */
     public function testThrowsExceptionOnUnsupportedWatchInProfile()
     {
+        $profile = $this->getMock('Predis\Profile\ProfileInterface');
+        $profile->expects($this->once())
+                ->method('supportsCommands')
+                ->with(array('MULTI', 'EXEC', 'DISCARD'))
+                ->will($this->returnValue(true));
+        $profile->expects($this->once())
+                ->method('supportsCommand')
+                ->with('WATCH')
+                ->will($this->returnValue(false));
+
         $connection = $this->getMock('Predis\Connection\NodeConnectionInterface');
-        $client = new Client($connection, array('profile' => '2.0'));
-        $tx = new MultiExec($client, array('options' => 'cas'));
+        $client = new Client($connection, array('profile' => $profile));
 
+        $tx = new MultiExec($client, array('options' => 'cas'));
         $tx->watch('foo');
     }
 
@@ -54,8 +71,19 @@ class MultiExecTest extends PredisTestCase
      */
     public function testThrowsExceptionOnUnsupportedUnwatchInProfile()
     {
+        $profile = $this->getMock('Predis\Profile\ProfileInterface');
+        $profile->expects($this->once())
+                ->method('supportsCommands')
+                ->with(array('MULTI', 'EXEC', 'DISCARD'))
+                ->will($this->returnValue(true));
+        $profile->expects($this->once())
+                ->method('supportsCommand')
+                ->with('UNWATCH')
+                ->will($this->returnValue(false));
+
         $connection = $this->getMock('Predis\Connection\NodeConnectionInterface');
-        $client = new Client($connection, array('profile' => '2.0'));
+        $client = new Client($connection, array('profile' => $profile));
+
         $tx = new MultiExec($client, array('options' => 'cas'));
 
         $tx->unwatch('foo');