Permalink
Browse files

Make sure client is alive on Rack store.

  • Loading branch information...
1 parent 99c62c4 commit 13cef1f868e35554ed4c20a9e780dc76b6e26e7c @arthurnn arthurnn committed Jan 9, 2014
Showing with 8 additions and 2 deletions.
  1. +6 −0 lib/dalli/client.rb
  2. +1 −0 lib/rack/session/dalli.rb
  3. +1 −2 test/test_rack_session.rb
View
@@ -213,6 +213,12 @@ def reset_stats
end
##
+ ## Make sure memcache servers are alive, or raise an Dalli::RingError
+ def alive!
+ ring.server_for_key("")
+ end
+
+ ##
## Version of the memcache servers.
def version
values = {}
@@ -16,6 +16,7 @@ def initialize(app, options={})
mserv = @default_options[:memcache_server]
mopts = @default_options.reject{|k,v| !DEFAULT_OPTIONS.include? k }
@pool = options[:cache] || ::Dalli::Client.new(mserv, mopts)
+ @pool.alive!
end
def generate_sid
@@ -55,8 +55,7 @@
it "faults on no connection" do
assert_raises Dalli::RingError do
- rsd = Rack::Session::Dalli.new(incrementor, :memcache_server => 'nosuchserver')
- rsd.pool.set('ping', '')
+ Rack::Session::Dalli.new(incrementor, :memcache_server => 'nosuchserver')
end
end

0 comments on commit 13cef1f

Please sign in to comment.