From 167a68cae7a1026c0820ea3e1b9844b466ba0110 Mon Sep 17 00:00:00 2001 From: Paul Damer Date: Mon, 18 May 2015 13:53:45 -0400 Subject: [PATCH] make brpoplpush work with the default 0 timeout or empty timeout options --- lib/redis/namespace.rb | 5 ++++- spec/redis_spec.rb | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/redis/namespace.rb b/lib/redis/namespace.rb index fa3b34d..96266dc 100644 --- a/lib/redis/namespace.rb +++ b/lib/redis/namespace.rb @@ -59,7 +59,7 @@ class Namespace "bitop" => [ :exclude_first ], "blpop" => [ :exclude_last, :first ], "brpop" => [ :exclude_last, :first ], - "brpoplpush" => [ :exclude_last ], + "brpoplpush" => [ :first_two ], "debug" => [ :exclude_first ], "decr" => [ :first ], "decrby" => [ :first ], @@ -367,6 +367,9 @@ def call_with_namespace(command, *args, &block) case before when :first args[0] = add_namespace(args[0]) if args[0] + when :first_two + args[0] = add_namespace(args[0]) if args[0] + args[1] = add_namespace(args[1]) if args[1] when :all args = add_namespace(args) when :exclude_first diff --git a/spec/redis_spec.rb b/spec/redis_spec.rb index 885b4dc..0fe952c 100644 --- a/spec/redis_spec.rb +++ b/spec/redis_spec.rb @@ -84,6 +84,13 @@ @namespaced.lrange('bar',0,-1).should eq(['bar']) end + it 'should be able to use a namespace with brpoplpush with default timeout' do + @namespaced.lpush('foo','bar') + @namespaced.brpoplpush('foo','bar').should eq('bar') + @namespaced.lrange('foo',0,-1).should eq([]) + @namespaced.lrange('bar',0,-1).should eq(['bar']) + end + it 'should be able to use a namespace with getbit' do @namespaced.set('foo','bar') @namespaced.getbit('foo',1).should eq(1)