redis 4.0.1 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/CHANGELOG.md +38 -0
 - data/README.md +46 -1
 - data/lib/redis/client.rb +29 -12
 - data/lib/redis/cluster/command.rb +81 -0
 - data/lib/redis/cluster/command_loader.rb +34 -0
 - data/lib/redis/cluster/key_slot_converter.rb +72 -0
 - data/lib/redis/cluster/node.rb +104 -0
 - data/lib/redis/cluster/node_key.rb +35 -0
 - data/lib/redis/cluster/node_loader.rb +37 -0
 - data/lib/redis/cluster/option.rb +77 -0
 - data/lib/redis/cluster/slot.rb +69 -0
 - data/lib/redis/cluster/slot_loader.rb +49 -0
 - data/lib/redis/cluster.rb +286 -0
 - data/lib/redis/connection/ruby.rb +5 -2
 - data/lib/redis/distributed.rb +13 -6
 - data/lib/redis/errors.rb +46 -0
 - data/lib/redis/pipeline.rb +9 -1
 - data/lib/redis/version.rb +1 -1
 - data/lib/redis.rb +692 -25
 - metadata +27 -184
 - data/.gitignore +0 -16
 - data/.travis/Gemfile +0 -13
 - data/.travis.yml +0 -73
 - data/.yardopts +0 -3
 - data/Gemfile +0 -3
 - data/benchmarking/logging.rb +0 -71
 - data/benchmarking/pipeline.rb +0 -51
 - data/benchmarking/speed.rb +0 -21
 - data/benchmarking/suite.rb +0 -24
 - data/benchmarking/worker.rb +0 -71
 - data/bors.toml +0 -14
 - data/examples/basic.rb +0 -15
 - data/examples/consistency.rb +0 -114
 - data/examples/dist_redis.rb +0 -43
 - data/examples/incr-decr.rb +0 -17
 - data/examples/list.rb +0 -26
 - data/examples/pubsub.rb +0 -37
 - data/examples/sentinel/sentinel.conf +0 -9
 - data/examples/sentinel/start +0 -49
 - data/examples/sentinel.rb +0 -41
 - data/examples/sets.rb +0 -36
 - data/examples/unicorn/config.ru +0 -3
 - data/examples/unicorn/unicorn.rb +0 -20
 - data/makefile +0 -42
 - data/redis.gemspec +0 -42
 - data/test/bitpos_test.rb +0 -63
 - data/test/blocking_commands_test.rb +0 -40
 - data/test/client_test.rb +0 -59
 - data/test/command_map_test.rb +0 -28
 - data/test/commands_on_hashes_test.rb +0 -19
 - data/test/commands_on_hyper_log_log_test.rb +0 -19
 - data/test/commands_on_lists_test.rb +0 -18
 - data/test/commands_on_sets_test.rb +0 -75
 - data/test/commands_on_sorted_sets_test.rb +0 -150
 - data/test/commands_on_strings_test.rb +0 -99
 - data/test/commands_on_value_types_test.rb +0 -171
 - data/test/connection_handling_test.rb +0 -275
 - data/test/connection_test.rb +0 -57
 - data/test/db/.gitkeep +0 -0
 - data/test/distributed_blocking_commands_test.rb +0 -44
 - data/test/distributed_commands_on_hashes_test.rb +0 -8
 - data/test/distributed_commands_on_hyper_log_log_test.rb +0 -31
 - data/test/distributed_commands_on_lists_test.rb +0 -20
 - data/test/distributed_commands_on_sets_test.rb +0 -106
 - data/test/distributed_commands_on_sorted_sets_test.rb +0 -16
 - data/test/distributed_commands_on_strings_test.rb +0 -69
 - data/test/distributed_commands_on_value_types_test.rb +0 -93
 - data/test/distributed_commands_requiring_clustering_test.rb +0 -162
 - data/test/distributed_connection_handling_test.rb +0 -21
 - data/test/distributed_internals_test.rb +0 -68
 - data/test/distributed_key_tags_test.rb +0 -50
 - data/test/distributed_persistence_control_commands_test.rb +0 -24
 - data/test/distributed_publish_subscribe_test.rb +0 -90
 - data/test/distributed_remote_server_control_commands_test.rb +0 -64
 - data/test/distributed_scripting_test.rb +0 -100
 - data/test/distributed_sorting_test.rb +0 -18
 - data/test/distributed_test.rb +0 -56
 - data/test/distributed_transactions_test.rb +0 -30
 - data/test/encoding_test.rb +0 -14
 - data/test/error_replies_test.rb +0 -57
 - data/test/fork_safety_test.rb +0 -60
 - data/test/helper.rb +0 -201
 - data/test/helper_test.rb +0 -22
 - data/test/internals_test.rb +0 -389
 - data/test/lint/blocking_commands.rb +0 -150
 - data/test/lint/hashes.rb +0 -162
 - data/test/lint/hyper_log_log.rb +0 -60
 - data/test/lint/lists.rb +0 -143
 - data/test/lint/sets.rb +0 -140
 - data/test/lint/sorted_sets.rb +0 -316
 - data/test/lint/strings.rb +0 -246
 - data/test/lint/value_types.rb +0 -130
 - data/test/persistence_control_commands_test.rb +0 -24
 - data/test/pipelining_commands_test.rb +0 -238
 - data/test/publish_subscribe_test.rb +0 -280
 - data/test/remote_server_control_commands_test.rb +0 -175
 - data/test/scanning_test.rb +0 -407
 - data/test/scripting_test.rb +0 -76
 - data/test/sentinel_command_test.rb +0 -78
 - data/test/sentinel_test.rb +0 -253
 - data/test/sorting_test.rb +0 -57
 - data/test/ssl_test.rb +0 -69
 - data/test/support/connection/hiredis.rb +0 -1
 - data/test/support/connection/ruby.rb +0 -1
 - data/test/support/connection/synchrony.rb +0 -17
 - data/test/support/redis_mock.rb +0 -130
 - data/test/support/ssl/gen_certs.sh +0 -31
 - data/test/support/ssl/trusted-ca.crt +0 -25
 - data/test/support/ssl/trusted-ca.key +0 -27
 - data/test/support/ssl/trusted-cert.crt +0 -81
 - data/test/support/ssl/trusted-cert.key +0 -28
 - data/test/support/ssl/untrusted-ca.crt +0 -26
 - data/test/support/ssl/untrusted-ca.key +0 -27
 - data/test/support/ssl/untrusted-cert.crt +0 -82
 - data/test/support/ssl/untrusted-cert.key +0 -28
 - data/test/support/wire/synchrony.rb +0 -24
 - data/test/support/wire/thread.rb +0 -5
 - data/test/synchrony_driver.rb +0 -85
 - data/test/test.conf.erb +0 -9
 - data/test/thread_safety_test.rb +0 -60
 - data/test/transactions_test.rb +0 -262
 - data/test/unknown_commands_test.rb +0 -12
 - data/test/url_param_test.rb +0 -136
 
| 
         @@ -1,275 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require_relative "helper"
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            class TestConnectionHandling < Test::Unit::TestCase
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
              include Helper::Client
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
              def test_auth
         
     | 
| 
       8 
     | 
    
         
            -
                commands = {
         
     | 
| 
       9 
     | 
    
         
            -
                  :auth => lambda { |password| $auth = password; "+OK" },
         
     | 
| 
       10 
     | 
    
         
            -
                  :get  => lambda { |key| $auth == "secret" ? "$3\r\nbar" : "$-1" },
         
     | 
| 
       11 
     | 
    
         
            -
                }
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
                redis_mock(commands, :password => "secret") do |redis|
         
     | 
| 
       14 
     | 
    
         
            -
                  assert_equal "bar", redis.get("foo")
         
     | 
| 
       15 
     | 
    
         
            -
                end
         
     | 
| 
       16 
     | 
    
         
            -
              end
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
              def test_id
         
     | 
| 
       19 
     | 
    
         
            -
                commands = {
         
     | 
| 
       20 
     | 
    
         
            -
                  :client => lambda { |cmd, name| $name = [cmd, name]; "+OK" },
         
     | 
| 
       21 
     | 
    
         
            -
                  :ping  => lambda { "+PONG" },
         
     | 
| 
       22 
     | 
    
         
            -
                }
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
                redis_mock(commands, :id => "client-name") do |redis|
         
     | 
| 
       25 
     | 
    
         
            -
                  assert_equal "PONG", redis.ping
         
     | 
| 
       26 
     | 
    
         
            -
                end
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
                assert_equal ["setname","client-name"], $name
         
     | 
| 
       29 
     | 
    
         
            -
              end
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
              def test_ping
         
     | 
| 
       32 
     | 
    
         
            -
                assert_equal "PONG", r.ping
         
     | 
| 
       33 
     | 
    
         
            -
              end
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
              def test_select
         
     | 
| 
       36 
     | 
    
         
            -
                r.set "foo", "bar"
         
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
                r.select 14
         
     | 
| 
       39 
     | 
    
         
            -
                assert_equal nil, r.get("foo")
         
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
                r._client.disconnect
         
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
                assert_equal nil, r.get("foo")
         
     | 
| 
       44 
     | 
    
         
            -
              end
         
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
              def test_quit
         
     | 
| 
       47 
     | 
    
         
            -
                r.quit
         
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
                assert !r._client.connected?
         
     | 
| 
       50 
     | 
    
         
            -
              end
         
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
              def test_close
         
     | 
| 
       53 
     | 
    
         
            -
                quit = 0
         
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
                commands = {
         
     | 
| 
       56 
     | 
    
         
            -
                  :quit => lambda do
         
     | 
| 
       57 
     | 
    
         
            -
                    quit += 1
         
     | 
| 
       58 
     | 
    
         
            -
                    "+OK"
         
     | 
| 
       59 
     | 
    
         
            -
                  end
         
     | 
| 
       60 
     | 
    
         
            -
                }
         
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
                redis_mock(commands) do |redis|
         
     | 
| 
       63 
     | 
    
         
            -
                  assert_equal 0, quit
         
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
                  redis.quit
         
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
                  assert_equal 1, quit
         
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
                  redis.ping
         
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
                  redis.close
         
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
                  assert_equal 1, quit
         
     | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
       75 
     | 
    
         
            -
                  assert !redis.connected?
         
     | 
| 
       76 
     | 
    
         
            -
                end
         
     | 
| 
       77 
     | 
    
         
            -
              end
         
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
       79 
     | 
    
         
            -
              def test_disconnect
         
     | 
| 
       80 
     | 
    
         
            -
                quit = 0
         
     | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
       82 
     | 
    
         
            -
                commands = {
         
     | 
| 
       83 
     | 
    
         
            -
                  :quit => lambda do
         
     | 
| 
       84 
     | 
    
         
            -
                    quit += 1
         
     | 
| 
       85 
     | 
    
         
            -
                    "+OK"
         
     | 
| 
       86 
     | 
    
         
            -
                  end
         
     | 
| 
       87 
     | 
    
         
            -
                }
         
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
                redis_mock(commands) do |redis|
         
     | 
| 
       90 
     | 
    
         
            -
                  assert_equal 0, quit
         
     | 
| 
       91 
     | 
    
         
            -
             
     | 
| 
       92 
     | 
    
         
            -
                  redis.quit
         
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
       94 
     | 
    
         
            -
                  assert_equal 1, quit
         
     | 
| 
       95 
     | 
    
         
            -
             
     | 
| 
       96 
     | 
    
         
            -
                  redis.ping
         
     | 
| 
       97 
     | 
    
         
            -
             
     | 
| 
       98 
     | 
    
         
            -
                  redis.disconnect!
         
     | 
| 
       99 
     | 
    
         
            -
             
     | 
| 
       100 
     | 
    
         
            -
                  assert_equal 1, quit
         
     | 
| 
       101 
     | 
    
         
            -
             
     | 
| 
       102 
     | 
    
         
            -
                  assert !redis.connected?
         
     | 
| 
       103 
     | 
    
         
            -
                end
         
     | 
| 
       104 
     | 
    
         
            -
              end
         
     | 
| 
       105 
     | 
    
         
            -
             
     | 
| 
       106 
     | 
    
         
            -
              def test_shutdown
         
     | 
| 
       107 
     | 
    
         
            -
                commands = {
         
     | 
| 
       108 
     | 
    
         
            -
                  :shutdown => lambda { :exit }
         
     | 
| 
       109 
     | 
    
         
            -
                }
         
     | 
| 
       110 
     | 
    
         
            -
             
     | 
| 
       111 
     | 
    
         
            -
                redis_mock(commands) do |redis|
         
     | 
| 
       112 
     | 
    
         
            -
                  # SHUTDOWN does not reply: test that it does not raise here.
         
     | 
| 
       113 
     | 
    
         
            -
                  assert_equal nil, redis.shutdown
         
     | 
| 
       114 
     | 
    
         
            -
                end
         
     | 
| 
       115 
     | 
    
         
            -
              end
         
     | 
| 
       116 
     | 
    
         
            -
             
     | 
| 
       117 
     | 
    
         
            -
              def test_shutdown_with_error
         
     | 
| 
       118 
     | 
    
         
            -
                connections = 0
         
     | 
| 
       119 
     | 
    
         
            -
                commands = {
         
     | 
| 
       120 
     | 
    
         
            -
                  :select => lambda { |*_| connections += 1; "+OK\r\n" },
         
     | 
| 
       121 
     | 
    
         
            -
                  :connections => lambda { ":#{connections}\r\n" },
         
     | 
| 
       122 
     | 
    
         
            -
                  :shutdown => lambda { "-ERR could not shutdown\r\n" }
         
     | 
| 
       123 
     | 
    
         
            -
                }
         
     | 
| 
       124 
     | 
    
         
            -
             
     | 
| 
       125 
     | 
    
         
            -
                redis_mock(commands) do |redis|
         
     | 
| 
       126 
     | 
    
         
            -
                  connections = redis.connections
         
     | 
| 
       127 
     | 
    
         
            -
             
     | 
| 
       128 
     | 
    
         
            -
                  # SHUTDOWN replies with an error: test that it gets raised
         
     | 
| 
       129 
     | 
    
         
            -
                  assert_raise Redis::CommandError do
         
     | 
| 
       130 
     | 
    
         
            -
                    redis.shutdown
         
     | 
| 
       131 
     | 
    
         
            -
                  end
         
     | 
| 
       132 
     | 
    
         
            -
             
     | 
| 
       133 
     | 
    
         
            -
                  # The connection should remain in tact
         
     | 
| 
       134 
     | 
    
         
            -
                  assert_equal connections, redis.connections
         
     | 
| 
       135 
     | 
    
         
            -
                end
         
     | 
| 
       136 
     | 
    
         
            -
              end
         
     | 
| 
       137 
     | 
    
         
            -
             
     | 
| 
       138 
     | 
    
         
            -
              def test_shutdown_from_pipeline
         
     | 
| 
       139 
     | 
    
         
            -
                commands = {
         
     | 
| 
       140 
     | 
    
         
            -
                  :shutdown => lambda { :exit }
         
     | 
| 
       141 
     | 
    
         
            -
                }
         
     | 
| 
       142 
     | 
    
         
            -
             
     | 
| 
       143 
     | 
    
         
            -
                redis_mock(commands) do |redis|
         
     | 
| 
       144 
     | 
    
         
            -
                  result = redis.pipelined do
         
     | 
| 
       145 
     | 
    
         
            -
                    redis.shutdown
         
     | 
| 
       146 
     | 
    
         
            -
                  end
         
     | 
| 
       147 
     | 
    
         
            -
             
     | 
| 
       148 
     | 
    
         
            -
                  assert_equal nil, result
         
     | 
| 
       149 
     | 
    
         
            -
                  assert !redis._client.connected?
         
     | 
| 
       150 
     | 
    
         
            -
                end
         
     | 
| 
       151 
     | 
    
         
            -
              end
         
     | 
| 
       152 
     | 
    
         
            -
             
     | 
| 
       153 
     | 
    
         
            -
              def test_shutdown_with_error_from_pipeline
         
     | 
| 
       154 
     | 
    
         
            -
                connections = 0
         
     | 
| 
       155 
     | 
    
         
            -
                commands = {
         
     | 
| 
       156 
     | 
    
         
            -
                  :select => lambda { |*_| connections += 1; "+OK\r\n" },
         
     | 
| 
       157 
     | 
    
         
            -
                  :connections => lambda { ":#{connections}\r\n" },
         
     | 
| 
       158 
     | 
    
         
            -
                  :shutdown => lambda { "-ERR could not shutdown\r\n" }
         
     | 
| 
       159 
     | 
    
         
            -
                }
         
     | 
| 
       160 
     | 
    
         
            -
             
     | 
| 
       161 
     | 
    
         
            -
                redis_mock(commands) do |redis|
         
     | 
| 
       162 
     | 
    
         
            -
                  connections = redis.connections
         
     | 
| 
       163 
     | 
    
         
            -
             
     | 
| 
       164 
     | 
    
         
            -
                  # SHUTDOWN replies with an error: test that it gets raised
         
     | 
| 
       165 
     | 
    
         
            -
                  assert_raise Redis::CommandError do
         
     | 
| 
       166 
     | 
    
         
            -
                    redis.pipelined do
         
     | 
| 
       167 
     | 
    
         
            -
                      redis.shutdown
         
     | 
| 
       168 
     | 
    
         
            -
                    end
         
     | 
| 
       169 
     | 
    
         
            -
                  end
         
     | 
| 
       170 
     | 
    
         
            -
             
     | 
| 
       171 
     | 
    
         
            -
                  # The connection should remain in tact
         
     | 
| 
       172 
     | 
    
         
            -
                  assert_equal connections, redis.connections
         
     | 
| 
       173 
     | 
    
         
            -
                end
         
     | 
| 
       174 
     | 
    
         
            -
              end
         
     | 
| 
       175 
     | 
    
         
            -
             
     | 
| 
       176 
     | 
    
         
            -
              def test_shutdown_from_multi_exec
         
     | 
| 
       177 
     | 
    
         
            -
                commands = {
         
     | 
| 
       178 
     | 
    
         
            -
                  :multi => lambda { "+OK\r\n" },
         
     | 
| 
       179 
     | 
    
         
            -
                  :shutdown => lambda { "+QUEUED\r\n" },
         
     | 
| 
       180 
     | 
    
         
            -
                  :exec => lambda { :exit }
         
     | 
| 
       181 
     | 
    
         
            -
                }
         
     | 
| 
       182 
     | 
    
         
            -
             
     | 
| 
       183 
     | 
    
         
            -
                redis_mock(commands) do |redis|
         
     | 
| 
       184 
     | 
    
         
            -
                  result = redis.multi do
         
     | 
| 
       185 
     | 
    
         
            -
                    redis.shutdown
         
     | 
| 
       186 
     | 
    
         
            -
                  end
         
     | 
| 
       187 
     | 
    
         
            -
             
     | 
| 
       188 
     | 
    
         
            -
                  assert_equal nil, result
         
     | 
| 
       189 
     | 
    
         
            -
                  assert !redis._client.connected?
         
     | 
| 
       190 
     | 
    
         
            -
                end
         
     | 
| 
       191 
     | 
    
         
            -
              end
         
     | 
| 
       192 
     | 
    
         
            -
             
     | 
| 
       193 
     | 
    
         
            -
              def test_shutdown_with_error_from_multi_exec
         
     | 
| 
       194 
     | 
    
         
            -
                connections = 0
         
     | 
| 
       195 
     | 
    
         
            -
                commands = {
         
     | 
| 
       196 
     | 
    
         
            -
                  :select => lambda { |*_| connections += 1; "+OK\r\n" },
         
     | 
| 
       197 
     | 
    
         
            -
                  :connections => lambda { ":#{connections}\r\n" },
         
     | 
| 
       198 
     | 
    
         
            -
                  :multi => lambda { "+OK\r\n" },
         
     | 
| 
       199 
     | 
    
         
            -
                  :shutdown => lambda { "+QUEUED\r\n" },
         
     | 
| 
       200 
     | 
    
         
            -
                  :exec => lambda { "*1\r\n-ERR could not shutdown\r\n" }
         
     | 
| 
       201 
     | 
    
         
            -
                }
         
     | 
| 
       202 
     | 
    
         
            -
             
     | 
| 
       203 
     | 
    
         
            -
                redis_mock(commands) do |redis|
         
     | 
| 
       204 
     | 
    
         
            -
                  connections = redis.connections
         
     | 
| 
       205 
     | 
    
         
            -
             
     | 
| 
       206 
     | 
    
         
            -
                  # SHUTDOWN replies with an error: test that it gets returned
         
     | 
| 
       207 
     | 
    
         
            -
                  # We should test for Redis::CommandError here, but hiredis doesn't yet do
         
     | 
| 
       208 
     | 
    
         
            -
                  # custom error classes.
         
     | 
| 
       209 
     | 
    
         
            -
                  err = nil
         
     | 
| 
       210 
     | 
    
         
            -
             
     | 
| 
       211 
     | 
    
         
            -
                  begin
         
     | 
| 
       212 
     | 
    
         
            -
                    redis.multi { redis.shutdown }
         
     | 
| 
       213 
     | 
    
         
            -
                  rescue => err
         
     | 
| 
       214 
     | 
    
         
            -
                  end
         
     | 
| 
       215 
     | 
    
         
            -
             
     | 
| 
       216 
     | 
    
         
            -
                  assert err.kind_of?(StandardError)
         
     | 
| 
       217 
     | 
    
         
            -
             
     | 
| 
       218 
     | 
    
         
            -
                  # The connection should remain intact
         
     | 
| 
       219 
     | 
    
         
            -
                  assert_equal connections, redis.connections
         
     | 
| 
       220 
     | 
    
         
            -
                end
         
     | 
| 
       221 
     | 
    
         
            -
              end
         
     | 
| 
       222 
     | 
    
         
            -
             
     | 
| 
       223 
     | 
    
         
            -
              def test_slaveof
         
     | 
| 
       224 
     | 
    
         
            -
                redis_mock(:slaveof => lambda { |host, port| "+SLAVEOF #{host} #{port}" }) do |redis|
         
     | 
| 
       225 
     | 
    
         
            -
                  assert_equal "SLAVEOF somehost 6381", redis.slaveof("somehost", 6381)
         
     | 
| 
       226 
     | 
    
         
            -
                end
         
     | 
| 
       227 
     | 
    
         
            -
              end
         
     | 
| 
       228 
     | 
    
         
            -
             
     | 
| 
       229 
     | 
    
         
            -
              def test_bgrewriteaof
         
     | 
| 
       230 
     | 
    
         
            -
                redis_mock(:bgrewriteaof => lambda { "+BGREWRITEAOF" }) do |redis|
         
     | 
| 
       231 
     | 
    
         
            -
                  assert_equal "BGREWRITEAOF", redis.bgrewriteaof
         
     | 
| 
       232 
     | 
    
         
            -
                end
         
     | 
| 
       233 
     | 
    
         
            -
              end
         
     | 
| 
       234 
     | 
    
         
            -
             
     | 
| 
       235 
     | 
    
         
            -
              def test_config_get
         
     | 
| 
       236 
     | 
    
         
            -
                assert r.config(:get, "*")["timeout"] != nil
         
     | 
| 
       237 
     | 
    
         
            -
             
     | 
| 
       238 
     | 
    
         
            -
                config = r.config(:get, "timeout")
         
     | 
| 
       239 
     | 
    
         
            -
                assert_equal ["timeout"], config.keys
         
     | 
| 
       240 
     | 
    
         
            -
                assert config.values.compact.size > 0
         
     | 
| 
       241 
     | 
    
         
            -
              end
         
     | 
| 
       242 
     | 
    
         
            -
             
     | 
| 
       243 
     | 
    
         
            -
              def test_config_set
         
     | 
| 
       244 
     | 
    
         
            -
                begin
         
     | 
| 
       245 
     | 
    
         
            -
                  assert_equal "OK", r.config(:set, "timeout", 200)
         
     | 
| 
       246 
     | 
    
         
            -
                  assert_equal "200", r.config(:get, "*")["timeout"]
         
     | 
| 
       247 
     | 
    
         
            -
             
     | 
| 
       248 
     | 
    
         
            -
                  assert_equal "OK", r.config(:set, "timeout", 100)
         
     | 
| 
       249 
     | 
    
         
            -
                  assert_equal "100", r.config(:get, "*")["timeout"]
         
     | 
| 
       250 
     | 
    
         
            -
                ensure
         
     | 
| 
       251 
     | 
    
         
            -
                  r.config :set, "timeout", 300
         
     | 
| 
       252 
     | 
    
         
            -
                end
         
     | 
| 
       253 
     | 
    
         
            -
              end
         
     | 
| 
       254 
     | 
    
         
            -
             
     | 
| 
       255 
     | 
    
         
            -
              driver(:ruby, :hiredis) do
         
     | 
| 
       256 
     | 
    
         
            -
                def test_consistency_on_multithreaded_env
         
     | 
| 
       257 
     | 
    
         
            -
                  t = nil
         
     | 
| 
       258 
     | 
    
         
            -
             
     | 
| 
       259 
     | 
    
         
            -
                  commands = {
         
     | 
| 
       260 
     | 
    
         
            -
                    :set => lambda { |key, value| t.kill; "+OK\r\n" },
         
     | 
| 
       261 
     | 
    
         
            -
                    :incr => lambda { |key| ":1\r\n" },
         
     | 
| 
       262 
     | 
    
         
            -
                  }
         
     | 
| 
       263 
     | 
    
         
            -
             
     | 
| 
       264 
     | 
    
         
            -
                  redis_mock(commands) do |redis|
         
     | 
| 
       265 
     | 
    
         
            -
                    t = Thread.new do
         
     | 
| 
       266 
     | 
    
         
            -
                      redis.set("foo", "bar")
         
     | 
| 
       267 
     | 
    
         
            -
                    end
         
     | 
| 
       268 
     | 
    
         
            -
             
     | 
| 
       269 
     | 
    
         
            -
                    t.join
         
     | 
| 
       270 
     | 
    
         
            -
             
     | 
| 
       271 
     | 
    
         
            -
                    assert_equal 1, redis.incr("baz")
         
     | 
| 
       272 
     | 
    
         
            -
                  end
         
     | 
| 
       273 
     | 
    
         
            -
                end
         
     | 
| 
       274 
     | 
    
         
            -
              end
         
     | 
| 
       275 
     | 
    
         
            -
            end
         
     | 
    
        data/test/connection_test.rb
    DELETED
    
    | 
         @@ -1,57 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require_relative "helper"
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            class TestConnection < Test::Unit::TestCase
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
              include Helper::Client
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
              def test_provides_a_meaningful_inspect
         
     | 
| 
       8 
     | 
    
         
            -
                assert_equal "#<Redis client v#{Redis::VERSION} for redis://127.0.0.1:#{PORT}/15>", r.inspect
         
     | 
| 
       9 
     | 
    
         
            -
              end
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
              def test_connection_information
         
     | 
| 
       12 
     | 
    
         
            -
                assert_equal "127.0.0.1",                 r.connection.fetch(:host)
         
     | 
| 
       13 
     | 
    
         
            -
                assert_equal 6381,                        r.connection.fetch(:port)
         
     | 
| 
       14 
     | 
    
         
            -
                assert_equal 15,                          r.connection.fetch(:db)
         
     | 
| 
       15 
     | 
    
         
            -
                assert_equal "127.0.0.1:6381",            r.connection.fetch(:location)
         
     | 
| 
       16 
     | 
    
         
            -
                assert_equal "redis://127.0.0.1:6381/15", r.connection.fetch(:id)
         
     | 
| 
       17 
     | 
    
         
            -
              end
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
              def test_default_id_with_host_and_port
         
     | 
| 
       20 
     | 
    
         
            -
                redis = Redis.new(OPTIONS.merge(:host => "host", :port => "1234", :db => 0))
         
     | 
| 
       21 
     | 
    
         
            -
                assert_equal "redis://host:1234/0", redis.connection.fetch(:id)
         
     | 
| 
       22 
     | 
    
         
            -
              end
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
              def test_default_id_with_host_and_port_and_explicit_scheme
         
     | 
| 
       25 
     | 
    
         
            -
                redis = Redis.new(OPTIONS.merge(:host => "host", :port => "1234", :db => 0, :scheme => "foo"))
         
     | 
| 
       26 
     | 
    
         
            -
                assert_equal "redis://host:1234/0", redis.connection.fetch(:id)
         
     | 
| 
       27 
     | 
    
         
            -
              end
         
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
              def test_default_id_with_path
         
     | 
| 
       30 
     | 
    
         
            -
                redis = Redis.new(OPTIONS.merge(:path => "/tmp/redis.sock", :db => 0))
         
     | 
| 
       31 
     | 
    
         
            -
                assert_equal "redis:///tmp/redis.sock/0", redis.connection.fetch(:id)
         
     | 
| 
       32 
     | 
    
         
            -
              end
         
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
              def test_default_id_with_path_and_explicit_scheme
         
     | 
| 
       35 
     | 
    
         
            -
                redis = Redis.new(OPTIONS.merge(:path => "/tmp/redis.sock", :db => 0, :scheme => "foo"))
         
     | 
| 
       36 
     | 
    
         
            -
                assert_equal "redis:///tmp/redis.sock/0", redis.connection.fetch(:id)
         
     | 
| 
       37 
     | 
    
         
            -
              end
         
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
              def test_override_id
         
     | 
| 
       40 
     | 
    
         
            -
                redis = Redis.new(OPTIONS.merge(:id => "test"))
         
     | 
| 
       41 
     | 
    
         
            -
                assert_equal "test", redis.connection.fetch(:id)
         
     | 
| 
       42 
     | 
    
         
            -
              end
         
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
              def test_id_inside_multi
         
     | 
| 
       45 
     | 
    
         
            -
                redis         = Redis.new(OPTIONS)
         
     | 
| 
       46 
     | 
    
         
            -
                id            = nil
         
     | 
| 
       47 
     | 
    
         
            -
                connection_id = nil
         
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
                redis.multi do
         
     | 
| 
       50 
     | 
    
         
            -
                  id            = redis.id
         
     | 
| 
       51 
     | 
    
         
            -
                  connection_id = redis.connection.fetch(:id)
         
     | 
| 
       52 
     | 
    
         
            -
                end
         
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
                assert_equal "redis://127.0.0.1:6381/15", id
         
     | 
| 
       55 
     | 
    
         
            -
                assert_equal "redis://127.0.0.1:6381/15", connection_id
         
     | 
| 
       56 
     | 
    
         
            -
              end
         
     | 
| 
       57 
     | 
    
         
            -
            end
         
     | 
    
        data/test/db/.gitkeep
    DELETED
    
    | 
         
            File without changes
         
     | 
| 
         @@ -1,44 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require_relative "helper"
         
     | 
| 
       2 
     | 
    
         
            -
            require_relative "lint/blocking_commands"
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            class TestDistributedBlockingCommands < Test::Unit::TestCase
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
              include Helper::Distributed
         
     | 
| 
       7 
     | 
    
         
            -
              include Lint::BlockingCommands
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
              def test_blpop_raises
         
     | 
| 
       10 
     | 
    
         
            -
                assert_raises(Redis::Distributed::CannotDistribute) do
         
     | 
| 
       11 
     | 
    
         
            -
                  r.blpop(["foo", "bar"])
         
     | 
| 
       12 
     | 
    
         
            -
                end
         
     | 
| 
       13 
     | 
    
         
            -
              end
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
              def test_blpop_raises_with_old_prototype
         
     | 
| 
       16 
     | 
    
         
            -
                assert_raises(Redis::Distributed::CannotDistribute) do
         
     | 
| 
       17 
     | 
    
         
            -
                  r.blpop("foo", "bar", 0)
         
     | 
| 
       18 
     | 
    
         
            -
                end
         
     | 
| 
       19 
     | 
    
         
            -
              end
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
              def test_brpop_raises
         
     | 
| 
       22 
     | 
    
         
            -
                assert_raises(Redis::Distributed::CannotDistribute) do
         
     | 
| 
       23 
     | 
    
         
            -
                  r.brpop(["foo", "bar"])
         
     | 
| 
       24 
     | 
    
         
            -
                end
         
     | 
| 
       25 
     | 
    
         
            -
              end
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
              def test_brpop_raises_with_old_prototype
         
     | 
| 
       28 
     | 
    
         
            -
                assert_raises(Redis::Distributed::CannotDistribute) do
         
     | 
| 
       29 
     | 
    
         
            -
                  r.brpop("foo", "bar", 0)
         
     | 
| 
       30 
     | 
    
         
            -
                end
         
     | 
| 
       31 
     | 
    
         
            -
              end
         
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
              def test_brpoplpush_raises
         
     | 
| 
       34 
     | 
    
         
            -
                assert_raises(Redis::Distributed::CannotDistribute) do
         
     | 
| 
       35 
     | 
    
         
            -
                  r.brpoplpush("foo", "bar")
         
     | 
| 
       36 
     | 
    
         
            -
                end
         
     | 
| 
       37 
     | 
    
         
            -
              end
         
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
              def test_brpoplpush_raises_with_old_prototype
         
     | 
| 
       40 
     | 
    
         
            -
                assert_raises(Redis::Distributed::CannotDistribute) do
         
     | 
| 
       41 
     | 
    
         
            -
                  r.brpoplpush("foo", "bar", 0)
         
     | 
| 
       42 
     | 
    
         
            -
                end
         
     | 
| 
       43 
     | 
    
         
            -
              end
         
     | 
| 
       44 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,31 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require_relative "helper"
         
     | 
| 
       2 
     | 
    
         
            -
            require_relative "lint/hyper_log_log"
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            class TestDistributedCommandsOnHyperLogLog < Test::Unit::TestCase
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
              include Helper::Distributed
         
     | 
| 
       7 
     | 
    
         
            -
              include Lint::HyperLogLog
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
              def test_pfmerge
         
     | 
| 
       10 
     | 
    
         
            -
                target_version "2.8.9" do
         
     | 
| 
       11 
     | 
    
         
            -
                  assert_raise Redis::Distributed::CannotDistribute do
         
     | 
| 
       12 
     | 
    
         
            -
                    r.pfadd "foo", "s1"
         
     | 
| 
       13 
     | 
    
         
            -
                    r.pfadd "bar", "s2"
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
                    assert r.pfmerge("res", "foo", "bar")
         
     | 
| 
       16 
     | 
    
         
            -
                  end
         
     | 
| 
       17 
     | 
    
         
            -
                end
         
     | 
| 
       18 
     | 
    
         
            -
              end
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
              def test_pfcount_multiple_keys_diff_nodes
         
     | 
| 
       21 
     | 
    
         
            -
                target_version "2.8.9" do
         
     | 
| 
       22 
     | 
    
         
            -
                  assert_raise Redis::Distributed::CannotDistribute do
         
     | 
| 
       23 
     | 
    
         
            -
                    r.pfadd "foo", "s1"
         
     | 
| 
       24 
     | 
    
         
            -
                    r.pfadd "bar", "s2"
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
                    assert r.pfcount("res", "foo", "bar")
         
     | 
| 
       27 
     | 
    
         
            -
                  end
         
     | 
| 
       28 
     | 
    
         
            -
                end
         
     | 
| 
       29 
     | 
    
         
            -
              end
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,20 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require_relative "helper"
         
     | 
| 
       2 
     | 
    
         
            -
            require_relative "lint/lists"
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            class TestDistributedCommandsOnLists < Test::Unit::TestCase
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
              include Helper::Distributed
         
     | 
| 
       7 
     | 
    
         
            -
              include Lint::Lists
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
              def test_rpoplpush
         
     | 
| 
       10 
     | 
    
         
            -
                assert_raise Redis::Distributed::CannotDistribute do
         
     | 
| 
       11 
     | 
    
         
            -
                  r.rpoplpush("foo", "bar")
         
     | 
| 
       12 
     | 
    
         
            -
                end
         
     | 
| 
       13 
     | 
    
         
            -
              end
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
              def test_brpoplpush
         
     | 
| 
       16 
     | 
    
         
            -
                assert_raise Redis::Distributed::CannotDistribute do
         
     | 
| 
       17 
     | 
    
         
            -
                  r.brpoplpush("foo", "bar", :timeout => 1)
         
     | 
| 
       18 
     | 
    
         
            -
                end
         
     | 
| 
       19 
     | 
    
         
            -
              end
         
     | 
| 
       20 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,106 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require_relative "helper"
         
     | 
| 
       2 
     | 
    
         
            -
            require_relative "lint/sets"
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            class TestDistributedCommandsOnSets < Test::Unit::TestCase
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
              include Helper::Distributed
         
     | 
| 
       7 
     | 
    
         
            -
              include Lint::Sets
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
              def test_smove
         
     | 
| 
       10 
     | 
    
         
            -
                assert_raise Redis::Distributed::CannotDistribute do
         
     | 
| 
       11 
     | 
    
         
            -
                  r.sadd "foo", "s1"
         
     | 
| 
       12 
     | 
    
         
            -
                  r.sadd "bar", "s2"
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
                  r.smove("foo", "bar", "s1")
         
     | 
| 
       15 
     | 
    
         
            -
                end
         
     | 
| 
       16 
     | 
    
         
            -
              end
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
              def test_sinter
         
     | 
| 
       19 
     | 
    
         
            -
                assert_raise Redis::Distributed::CannotDistribute do
         
     | 
| 
       20 
     | 
    
         
            -
                  r.sadd "foo", "s1"
         
     | 
| 
       21 
     | 
    
         
            -
                  r.sadd "foo", "s2"
         
     | 
| 
       22 
     | 
    
         
            -
                  r.sadd "bar", "s2"
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
                  r.sinter("foo", "bar")
         
     | 
| 
       25 
     | 
    
         
            -
                end
         
     | 
| 
       26 
     | 
    
         
            -
              end
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
              def test_sinterstore
         
     | 
| 
       29 
     | 
    
         
            -
                assert_raise Redis::Distributed::CannotDistribute do
         
     | 
| 
       30 
     | 
    
         
            -
                  r.sadd "foo", "s1"
         
     | 
| 
       31 
     | 
    
         
            -
                  r.sadd "foo", "s2"
         
     | 
| 
       32 
     | 
    
         
            -
                  r.sadd "bar", "s2"
         
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
                  r.sinterstore("baz", "foo", "bar")
         
     | 
| 
       35 
     | 
    
         
            -
                end
         
     | 
| 
       36 
     | 
    
         
            -
              end
         
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
              def test_sunion
         
     | 
| 
       39 
     | 
    
         
            -
                assert_raise Redis::Distributed::CannotDistribute do
         
     | 
| 
       40 
     | 
    
         
            -
                  r.sadd "foo", "s1"
         
     | 
| 
       41 
     | 
    
         
            -
                  r.sadd "foo", "s2"
         
     | 
| 
       42 
     | 
    
         
            -
                  r.sadd "bar", "s2"
         
     | 
| 
       43 
     | 
    
         
            -
                  r.sadd "bar", "s3"
         
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
                  r.sunion("foo", "bar")
         
     | 
| 
       46 
     | 
    
         
            -
                end
         
     | 
| 
       47 
     | 
    
         
            -
              end
         
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
              def test_sunionstore
         
     | 
| 
       50 
     | 
    
         
            -
                assert_raise Redis::Distributed::CannotDistribute do
         
     | 
| 
       51 
     | 
    
         
            -
                  r.sadd "foo", "s1"
         
     | 
| 
       52 
     | 
    
         
            -
                  r.sadd "foo", "s2"
         
     | 
| 
       53 
     | 
    
         
            -
                  r.sadd "bar", "s2"
         
     | 
| 
       54 
     | 
    
         
            -
                  r.sadd "bar", "s3"
         
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
       56 
     | 
    
         
            -
                  r.sunionstore("baz", "foo", "bar")
         
     | 
| 
       57 
     | 
    
         
            -
                end
         
     | 
| 
       58 
     | 
    
         
            -
              end
         
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
              def test_sdiff
         
     | 
| 
       61 
     | 
    
         
            -
                assert_raise Redis::Distributed::CannotDistribute do
         
     | 
| 
       62 
     | 
    
         
            -
                  r.sadd "foo", "s1"
         
     | 
| 
       63 
     | 
    
         
            -
                  r.sadd "foo", "s2"
         
     | 
| 
       64 
     | 
    
         
            -
                  r.sadd "bar", "s2"
         
     | 
| 
       65 
     | 
    
         
            -
                  r.sadd "bar", "s3"
         
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
                  r.sdiff("foo", "bar")
         
     | 
| 
       68 
     | 
    
         
            -
                end
         
     | 
| 
       69 
     | 
    
         
            -
              end
         
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
              def test_sdiffstore
         
     | 
| 
       72 
     | 
    
         
            -
                assert_raise Redis::Distributed::CannotDistribute do
         
     | 
| 
       73 
     | 
    
         
            -
                  r.sadd "foo", "s1"
         
     | 
| 
       74 
     | 
    
         
            -
                  r.sadd "foo", "s2"
         
     | 
| 
       75 
     | 
    
         
            -
                  r.sadd "bar", "s2"
         
     | 
| 
       76 
     | 
    
         
            -
                  r.sadd "bar", "s3"
         
     | 
| 
       77 
     | 
    
         
            -
             
     | 
| 
       78 
     | 
    
         
            -
                  r.sdiffstore("baz", "foo", "bar")
         
     | 
| 
       79 
     | 
    
         
            -
                end
         
     | 
| 
       80 
     | 
    
         
            -
              end
         
     | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
       82 
     | 
    
         
            -
              def test_sscan
         
     | 
| 
       83 
     | 
    
         
            -
                assert_nothing_raised do
         
     | 
| 
       84 
     | 
    
         
            -
                  r.sadd "foo", "s1"
         
     | 
| 
       85 
     | 
    
         
            -
                  r.sadd "foo", "s2"
         
     | 
| 
       86 
     | 
    
         
            -
                  r.sadd "bar", "s2"
         
     | 
| 
       87 
     | 
    
         
            -
                  r.sadd "bar", "s3"
         
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
                  cursor, vals = r.sscan "foo", 0
         
     | 
| 
       90 
     | 
    
         
            -
                  assert_equal '0', cursor
         
     | 
| 
       91 
     | 
    
         
            -
                  assert_equal %w(s1 s2), vals.sort
         
     | 
| 
       92 
     | 
    
         
            -
                end
         
     | 
| 
       93 
     | 
    
         
            -
              end
         
     | 
| 
       94 
     | 
    
         
            -
             
     | 
| 
       95 
     | 
    
         
            -
              def test_sscan_each
         
     | 
| 
       96 
     | 
    
         
            -
                assert_nothing_raised do
         
     | 
| 
       97 
     | 
    
         
            -
                  r.sadd "foo", "s1"
         
     | 
| 
       98 
     | 
    
         
            -
                  r.sadd "foo", "s2"
         
     | 
| 
       99 
     | 
    
         
            -
                  r.sadd "bar", "s2"
         
     | 
| 
       100 
     | 
    
         
            -
                  r.sadd "bar", "s3"
         
     | 
| 
       101 
     | 
    
         
            -
             
     | 
| 
       102 
     | 
    
         
            -
                  vals = r.sscan_each("foo").to_a
         
     | 
| 
       103 
     | 
    
         
            -
                  assert_equal %w(s1 s2), vals.sort
         
     | 
| 
       104 
     | 
    
         
            -
                end
         
     | 
| 
       105 
     | 
    
         
            -
              end
         
     | 
| 
       106 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,16 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require_relative "helper"
         
     | 
| 
       2 
     | 
    
         
            -
            require_relative "lint/sorted_sets"
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            class TestDistributedCommandsOnSortedSets < Test::Unit::TestCase
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
              include Helper::Distributed
         
     | 
| 
       7 
     | 
    
         
            -
              include Lint::SortedSets
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
              def test_zcount
         
     | 
| 
       10 
     | 
    
         
            -
                r.zadd "foo", 1, "s1"
         
     | 
| 
       11 
     | 
    
         
            -
                r.zadd "foo", 2, "s2"
         
     | 
| 
       12 
     | 
    
         
            -
                r.zadd "foo", 3, "s3"
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
                assert_equal 2, r.zcount("foo", 2, 3)
         
     | 
| 
       15 
     | 
    
         
            -
              end
         
     | 
| 
       16 
     | 
    
         
            -
            end
         
     | 
| 
         @@ -1,69 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require_relative "helper"
         
     | 
| 
       2 
     | 
    
         
            -
            require_relative "lint/strings"
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            class TestDistributedCommandsOnStrings < Test::Unit::TestCase
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
              include Helper::Distributed
         
     | 
| 
       7 
     | 
    
         
            -
              include Lint::Strings
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
              def test_mget
         
     | 
| 
       10 
     | 
    
         
            -
                r.set("foo", "s1")
         
     | 
| 
       11 
     | 
    
         
            -
                r.set("bar", "s2")
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
                assert_equal ["s1", "s2"]     , r.mget("foo", "bar")
         
     | 
| 
       14 
     | 
    
         
            -
                assert_equal ["s1", "s2", nil], r.mget("foo", "bar", "baz")
         
     | 
| 
       15 
     | 
    
         
            -
              end
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
              def test_mget_mapped
         
     | 
| 
       18 
     | 
    
         
            -
                r.set("foo", "s1")
         
     | 
| 
       19 
     | 
    
         
            -
                r.set("bar", "s2")
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
                response = r.mapped_mget("foo", "bar")
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
                assert_equal "s1", response["foo"]
         
     | 
| 
       24 
     | 
    
         
            -
                assert_equal "s2", response["bar"]
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
                response = r.mapped_mget("foo", "bar", "baz")
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
                assert_equal "s1", response["foo"]
         
     | 
| 
       29 
     | 
    
         
            -
                assert_equal "s2", response["bar"]
         
     | 
| 
       30 
     | 
    
         
            -
                assert_equal nil , response["baz"]
         
     | 
| 
       31 
     | 
    
         
            -
              end
         
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
              def test_mset
         
     | 
| 
       34 
     | 
    
         
            -
                assert_raise Redis::Distributed::CannotDistribute do
         
     | 
| 
       35 
     | 
    
         
            -
                  r.mset(:foo, "s1", :bar, "s2")
         
     | 
| 
       36 
     | 
    
         
            -
                end
         
     | 
| 
       37 
     | 
    
         
            -
              end
         
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
              def test_mset_mapped
         
     | 
| 
       40 
     | 
    
         
            -
                assert_raise Redis::Distributed::CannotDistribute do
         
     | 
| 
       41 
     | 
    
         
            -
                  r.mapped_mset(:foo => "s1", :bar => "s2")
         
     | 
| 
       42 
     | 
    
         
            -
                end
         
     | 
| 
       43 
     | 
    
         
            -
              end
         
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
              def test_msetnx
         
     | 
| 
       46 
     | 
    
         
            -
                assert_raise Redis::Distributed::CannotDistribute do
         
     | 
| 
       47 
     | 
    
         
            -
                  r.set("foo", "s1")
         
     | 
| 
       48 
     | 
    
         
            -
                  r.msetnx(:foo, "s2", :bar, "s3")
         
     | 
| 
       49 
     | 
    
         
            -
                end
         
     | 
| 
       50 
     | 
    
         
            -
              end
         
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
              def test_msetnx_mapped
         
     | 
| 
       53 
     | 
    
         
            -
                assert_raise Redis::Distributed::CannotDistribute do
         
     | 
| 
       54 
     | 
    
         
            -
                  r.set("foo", "s1")
         
     | 
| 
       55 
     | 
    
         
            -
                  r.mapped_msetnx(:foo => "s2", :bar => "s3")
         
     | 
| 
       56 
     | 
    
         
            -
                end
         
     | 
| 
       57 
     | 
    
         
            -
              end
         
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
              def test_bitop
         
     | 
| 
       60 
     | 
    
         
            -
                target_version "2.5.10" do
         
     | 
| 
       61 
     | 
    
         
            -
                  assert_raise Redis::Distributed::CannotDistribute do
         
     | 
| 
       62 
     | 
    
         
            -
                    r.set("foo", "a")
         
     | 
| 
       63 
     | 
    
         
            -
                    r.set("bar", "b")
         
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
                    r.bitop(:and, "foo&bar", "foo", "bar")
         
     | 
| 
       66 
     | 
    
         
            -
                  end
         
     | 
| 
       67 
     | 
    
         
            -
                end
         
     | 
| 
       68 
     | 
    
         
            -
              end
         
     | 
| 
       69 
     | 
    
         
            -
            end
         
     |