Skip to content

Commit

Permalink
Allow the error handler to be configured
Browse files Browse the repository at this point in the history
  • Loading branch information
brynary authored and fredjean committed Jan 21, 2010
1 parent 75834d9 commit d765121
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/memcache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def initialize(*args)

@client = MemCachedClient.new(@pool_name)

@client.error_handler = opts[:error_handler] if opts[:error_handler]
@client.primitiveAsString = true
@client.sanitizeKeys = false

Expand Down
9 changes: 9 additions & 0 deletions spec/jruby_memcache_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@
@client = MemCache.new([@server], :pool_name => 'new_pool')
@client.pool_name.should == 'new_pool'
end

it "should work with an error handler" do
include_class 'com.danga.MemCached.MemCachedClient'
java_memcache_client = mock.as_null_object
MemCachedClient.stub!(:new => java_memcache_client)
error_handler = Object.new
java_memcache_client.should_receive(:error_handler=).with(error_handler)
@client = MemCache.new([@server], :error_handler => error_handler)
end
end

describe "namespacing" do
Expand Down

0 comments on commit d765121

Please sign in to comment.