Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #431 from jaxi/feature/namespace_support_symbol

symbol support for namespace
  • Loading branch information...
commit e4a006e469b8abb413bbcb75c2928e602cf7a125 2 parents 5794335 + 222914f
@mperham authored
Showing with 19 additions and 1 deletion.
  1. +1 −0  History.md
  2. +1 −1  lib/dalli/client.rb
  3. +17 −0 test/test_dalli.rb
View
1  History.md
@@ -6,6 +6,7 @@ HEAD
- Rack session will check if servers are up on initialization (arthurnn, #423)
- Add support for IPv6 addresses in hex form, ie: "[::1]:11211" (dplummer, #428)
+- Add symbol support for namespace (jingkai #431)
2.7.0
==========
View
2  lib/dalli/client.rb
@@ -354,7 +354,7 @@ def key_without_namespace(key)
end
def namespace
- @options[:namespace].is_a?(Proc) ? @options[:namespace].call : @options[:namespace]
+ @options[:namespace].is_a?(Proc) ? @options[:namespace].call.to_s : @options[:namespace].to_s
end
def normalize_options(opts)
View
17 test/test_dalli.rb
@@ -23,6 +23,16 @@
end
end
end
+
+ it 'return string type for namespace attribute' do
+ dc = Dalli::Client.new('foo', :namespace => :wunderschoen)
+ assert_equal "wunderschoen", dc.send(:namespace)
+ dc.close
+
+ dc = Dalli::Client.new('foo', :namespace => Proc.new{:wunderschoen})
+ assert_equal "wunderschoen", dc.send(:namespace)
+ dc.close
+ end
end
describe 'key validation' do
@@ -42,6 +52,13 @@
end
end
end
+
+ it 'allow namespace to be a symbol' do
+ memcached(19122, '', :namespace => :wunderschoen) do |dc|
+ dc.set "x" * 251, 1
+ assert 1, dc.get("#{'x' * 200}:md5:#{Digest::MD5.hexdigest('x' * 251)}")
+ end
+ end
end
it "default to localhost:11211" do
Please sign in to comment.
Something went wrong with that request. Please try again.