Skip to content

Commit

Permalink
remcached: multi operation should return immediately if empty + spec
Browse files Browse the repository at this point in the history
  • Loading branch information
astro committed Oct 12, 2009
1 parent 86723e6 commit 07ab197
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/remcached.rb
Expand Up @@ -90,6 +90,11 @@ def delete(contents, &callback)
##

def multi_operation(request_klass, contents_list, &callback)
if contents_list.empty?
callback.call []
return self
end

results = {}

# Assemble client connections per keys
Expand Down
13 changes: 13 additions & 0 deletions spec/memcached_spec.rb
Expand Up @@ -250,6 +250,19 @@ def key(n)
}
end
end

context "when the multi operation is empty" do
it "should return immediately" do
@results = []
@calls = 0
Memcached.multi_add([]) { |responses|
@results += responses
@calls += 1
}
@results.should be_empty
@calls.should == 1
end
end
end

end

0 comments on commit 07ab197

Please sign in to comment.