Sha256: b01ed841d39c76732128b018b76acf8f1bad23a8adbdd4880c14c25bec987b55

Contents?: true

Size: 1.09 KB

Versions: 55

Compression:

Stored size: 1.09 KB

Contents

# encoding: UTF-8

require 'em-synchrony'

require 'redis'
require 'redis/connection/synchrony'

require File.expand_path("./helper", File.dirname(__FILE__))

#
# if running under Eventmachine + Synchrony (Ruby 1.9+), then
# we can simulate the blocking API while performing the network
# IO via the EM reactor.
#

EM.synchrony do
  r = Redis.new
  r.flushdb

  r.rpush "foo", "s1"
  r.rpush "foo", "s2"

  assert 2 == r.llen("foo")
  assert "s2" == r.rpop("foo")

  r.set("foo", "bar")

  assert "bar" == r.getset("foo", "baz")
  assert "baz" == r.get("foo")

  r.set("foo", "a")

  assert_equal 1, r.getbit("foo", 1)
  assert_equal 1, r.getbit("foo", 2)
  assert_equal 0, r.getbit("foo", 3)
  assert_equal 0, r.getbit("foo", 4)
  assert_equal 0, r.getbit("foo", 5)
  assert_equal 0, r.getbit("foo", 6)
  assert_equal 1, r.getbit("foo", 7)

  r.flushdb

  # command pipelining
  r.pipelined do
    r.lpush "foo", "s1"
    r.lpush "foo", "s2"
  end

  assert 2 == r.llen("foo")
  assert "s2" == r.lpop("foo")
  assert "s1" == r.lpop("foo")

  assert "OK" == r.client.call(:quit)
  assert "PONG" == r.ping

  EM.stop
end

Version data entries

55 entries across 55 versions & 7 rubygems

Version Path
classiccms-0.5.14 vendor/bundle/gems/redis-2.2.2/test/synchrony_driver.rb
classiccms-0.5.13 vendor/bundle/gems/redis-2.2.2/test/synchrony_driver.rb
classiccms-0.5.12 vendor/bundle/gems/redis-2.2.2/test/synchrony_driver.rb
classiccms-0.5.11 vendor/bundle/gems/redis-2.2.2/test/synchrony_driver.rb
classiccms-0.5.10 vendor/bundle/gems/redis-2.2.2/test/synchrony_driver.rb
classiccms-0.5.9 vendor/bundle/gems/redis-2.2.2/test/synchrony_driver.rb
classiccms-0.5.8 vendor/bundle/gems/redis-2.2.2/test/synchrony_driver.rb
classiccms-0.5.7 vendor/bundle/gems/redis-2.2.2/test/synchrony_driver.rb
classiccms-0.5.6 vendor/bundle/gems/redis-2.2.2/test/synchrony_driver.rb
classiccms-0.5.5 vendor/bundle/gems/redis-2.2.2/test/synchrony_driver.rb
classiccms-0.5.2 vendor/bundle/gems/redis-2.2.2/test/synchrony_driver.rb
classiccms-0.5.1 vendor/bundle/gems/redis-2.2.2/test/synchrony_driver.rb
classiccms-0.5.0 vendor/bundle/gems/redis-2.2.2/test/synchrony_driver.rb
classiccms-0.4.2 vendor/bundle/gems/redis-2.2.2/test/synchrony_driver.rb
classiccms-0.4.1 vendor/bundle/gems/redis-2.2.2/test/synchrony_driver.rb
classiccms-0.4.0 vendor/bundle/gems/redis-2.2.2/test/synchrony_driver.rb
classiccms-0.3.9 vendor/bundle/gems/redis-2.2.2/test/synchrony_driver.rb
classiccms-0.3.8 vendor/bundle/gems/redis-2.2.2/test/synchrony_driver.rb
classiccms-0.3.7 vendor/bundle/gems/redis-2.2.2/test/synchrony_driver.rb
classiccms-0.3.6 vendor/bundle/gems/redis-2.2.2/test/synchrony_driver.rb