Skip to content

Loading…

Bug with passing options to Memcached and Dalli via URI #32

Merged
merged 2 commits into from

2 participants

@kyledrake

This was missed because the tests weren't using the resolve to instantiate.

Fixes the bug. Feel free to move/DRY up the tests, I didn't spend too much time on it because I wanted to get this fix pushed as soon as possible.. it's stopping me from using em-synchrony with Dalli on our Heroku app.

@rtomayko
Owner

Thank you.

@rtomayko rtomayko merged commit 453897a into rtomayko:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Showing with 22 additions and 2 deletions.
  1. +1 −1 lib/rack/cache/entitystore.rb
  2. +1 −1 lib/rack/cache/metastore.rb
  3. +10 −0 test/entitystore_test.rb
  4. +10 −0 test/metastore_test.rb
View
2 lib/rack/cache/entitystore.rb
@@ -192,7 +192,7 @@ def self.resolve(uri)
when 'false' ; false
else value.to_sym
end
- options[k.to_sym] = value
+ options[key.to_sym] = value
end
options[:namespace] = uri.path.sub(/^\//, '')
new server, options
View
2 lib/rack/cache/metastore.rb
@@ -290,7 +290,7 @@ def self.resolve(uri)
when 'false' ; false
else value.to_sym
end
- options[k.to_sym] = value
+ options[key.to_sym] = value
end
options[:namespace] = uri.path.to_s.sub(/^\//, '')
View
10 test/entitystore_test.rb
@@ -185,6 +185,11 @@ def sha_like?
end
behaves_like 'A Rack::Cache::EntityStore Implementation'
end
+
+ it 'passes options from uri' do
+ memcached = Rack::Cache::EntityStore::Dalli.resolve URI.parse("memcached://#{ENV['MEMCACHED']}?show_backtraces=true")
+ memcached.cache.instance_variable_get(:@options)[:show_backtraces].should.equal true
+ end
end
@@ -198,6 +203,11 @@ def sha_like?
@store = nil
end
behaves_like 'A Rack::Cache::EntityStore Implementation'
+
+ it 'passes options from uri' do
+ dalli = Rack::Cache::EntityStore::Dalli.resolve URI.parse("memcached://#{ENV['MEMCACHED']}?compression=true")
+ dalli.cache.instance_variable_get(:@options)[:compression].should.equal true
+ end
end
end
View
10 test/metastore_test.rb
@@ -265,6 +265,11 @@ def self.call(request); request.path_info.reverse end
end
behaves_like 'A Rack::Cache::MetaStore Implementation'
end
+
+ it 'passes options from uri' do
+ memcached = Rack::Cache::EntityStore::Dalli.resolve URI.parse("memcached://#{ENV['MEMCACHED']}?show_backtraces=true")
+ memcached.cache.instance_variable_get(:@options)[:show_backtraces].should.equal true
+ end
end
need_dalli 'metastore tests' do
@@ -277,6 +282,11 @@ def self.call(request); request.path_info.reverse end
end
behaves_like 'A Rack::Cache::MetaStore Implementation'
end
+
+ it 'passes options from uri' do
+ dalli = Rack::Cache::EntityStore::Dalli.resolve URI.parse("memcached://#{ENV['MEMCACHED']}?compression=true")
+ dalli.cache.instance_variable_get(:@options)[:compression].should.equal true
+ end
end
need_java 'entity store testing' do
Something went wrong with that request. Please try again.