Sha256: 070e264a390ab428a0ce287bc5fe9afe9e54bf500427dfacb57e2c445a54be48
Contents?: true
Size: 891 Bytes
Versions: 1
Compression:
Stored size: 891 Bytes
Contents
require "spec_helper" describe "Thread-Safety" do include Redisrank::Database before(:each) do db.flushdb end #TODO should have more comprehensive thread-safe tests it "should incr in multiple threads" do threads = [] 50.times do threads << Thread.new { db.incr("spec:incr") } end threads.each { |t| t.join } db.get("spec:incr").should == "50" end it "should store event in multiple threads" do class ThreadSafetySpec include Redisrank::Model end threads = [] 50.times do threads << Thread.new { ThreadSafetySpec.store("spec:threadsafe", {:count => 1, :rand => rand(5)}) } end threads.each { |t| t.join } result = ThreadSafetySpec.fetch("spec:threadsafe", 5.hours.ago, 5.hours.from_now) result.total[:count].should == 50 result.total[:rand].should <= 250 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
redisrank-0.1.0 | spec/thread_safety_spec.rb |