Sha256: f0275462cf0a4d82f1ebc71c246ed799d11983b06ae813888b64ac0b4f9bb3b1

Contents?: true

Size: 571 Bytes

Versions: 11

Compression:

Stored size: 571 Bytes

Contents

# encoding: UTF-8

require "helper"

class TestThreadSafety < Test::Unit::TestCase

  include Helper::Client

  driver(:ruby, :hiredis) do
    def test_thread_safety
      redis = Redis.new(OPTIONS)
      redis.set "foo", 1
      redis.set "bar", 2

      sample = 100

      t1 = Thread.new do
        $foos = Array.new(sample) { redis.get "foo" }
      end

      t2 = Thread.new do
        $bars = Array.new(sample) { redis.get "bar" }
      end

      t1.join
      t2.join

      assert_equal ["1"], $foos.uniq
      assert_equal ["2"], $bars.uniq
    end
  end
end

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
redis-3.0.5 test/thread_safety_test.rb
sidekiq-statsd-0.1.1 vendor/ruby/1.9.1/gems/redis-3.0.4/test/thread_safety_test.rb
sidekiq-statsd-0.1.0 vendor/ruby/1.9.1/gems/redis-3.0.4/test/thread_safety_test.rb
redis-3.0.4 test/thread_safety_test.rb
redis-3.0.3 test/thread_safety_test.rb
remq-0.0.4 vendor/bundle/gems/redis-3.0.2/test/thread_safety_test.rb
remq-0.0.3 vendor/bundle/gems/redis-3.0.2/test/thread_safety_test.rb
redis-3.0.2 test/thread_safety_test.rb
redis-3.0.1 test/thread_safety_test.rb
redis-3.0.0 test/thread_safety_test.rb
redis-3.0.0.rc2 test/thread_safety_test.rb