Skip to content

Commit

Permalink
Remove redundant calls to namespace calculation and revise history.
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwlewis committed Jan 1, 2013
1 parent dfeb4e6 commit 16d29f4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 5 additions & 1 deletion History.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
Dalli Changelog
=====================

2.6.0
HEAD
=======

- Add lambda support for cache namespaces [joshwlewis, #311]

2.6.0
=======

- read_multi optimization, now checks local_cache [chendo, #306]
- Re-implement get_multi to be non-blocking [tmm1, #295]
- Add `dalli` accessor to dalli_store to access the underlying
Expand Down
7 changes: 3 additions & 4 deletions lib/dalli/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -340,19 +340,18 @@ def validate_key(key)
raise ArgumentError, "key cannot be blank" if !key || key.length == 0
key = key_with_namespace(key)
if key.length > 250
namespace_length = namespace ? namespace.size : 0
max_length_before_namespace = 212 - namespace_length
max_length_before_namespace = 212 - (namespace || '').size
key = "#{key[0, max_length_before_namespace]}:md5:#{Digest::MD5.hexdigest(key)}"
end
return key
end

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

def key_without_namespace(key)
namespace ? key.sub(%r(\A#{namespace}:), '') : key
(ns = namespace) ? key.sub(%r(\A#{ns}:), '') : key
end

def namespace
Expand Down

0 comments on commit 16d29f4

Please sign in to comment.