symbol support for namespace #431

Merged
merged 4 commits into from Jan 26, 2014

Projects

None yet

3 participants

@jaxi

If using syntax like

dc = Dalli::Client.new('foo', :namespace => :symbol_ns)

and the length of key is more than 250, Dalli will raise error like

#<NoMethodError: undefined method `size' for :symbol_ns:Symbol>

This pull request add symbol support for namespace so that there will be no errors raised when using this kind of syntax.

Please let me know if you have any advice.

BTW, there're 2 Sasl fails exist in the unit test of the master branch. I have no idea how to fix them so I just leave them there.

@mperham
Collaborator

You should call to_s on the Proc code path too

@jaxi

Yeah, you're right.

@mperham
Collaborator

And remove the extra file you added.

@jaxi

Sorry, do you mean the unit tests?

@mperham
Collaborator

No, you added a new file called :wunderschoen}

@mperham mperham merged commit e4a006e into petergoldstein:master Jan 26, 2014

1 check passed

Details default The Travis CI build passed
@mperham
Collaborator

Thanks!

@jaxi jaxi deleted the jaxi:feature/namespace_support_symbol branch Jan 26, 2014
@jaxi jaxi restored the jaxi:feature/namespace_support_symbol branch Jan 26, 2014
@jaxi jaxi deleted the jaxi:feature/namespace_support_symbol branch Jan 26, 2014
@sebastienluquet

The .to_s patch altered the namespace option that can not be nil anymore. Method like

def key_with_namespace(key)
  (ns = namespace) ? "#{ns}:#{key}" : key
end

will always add a colon on any key for serveur without namespace defined (typically rails ActiveSupport::MemCacheStore @data Dalli::Client)

sebastienluquet@8f5bab3 might be a quick fix, but the issue is may be somewhere else ?

@mperham
Collaborator

present? is a Rails-ism.

I would add return nil unless @options[:namespace] to the namespace method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment