Skip to content
This repository
Browse code

Remove redundant calls to namespace calculation and revise history.

  • Loading branch information...
commit 16d29f482fb6f2712e67df7b3ad3e124b3e2d46f 1 parent dfeb4e6
Josh W Lewis joshwlewis authored

Showing 2 changed files with 8 additions and 5 deletions. Show diff stats Hide diff stats

  1. +5 1 History.md
  2. +3 4 lib/dalli/client.rb
6 History.md
Source Rendered
... ... @@ -1,10 +1,14 @@
1 1 Dalli Changelog
2 2 =====================
3 3
4   -2.6.0
  4 +HEAD
5 5 =======
6 6
7 7 - Add lambda support for cache namespaces [joshwlewis, #311]
  8 +
  9 +2.6.0
  10 +=======
  11 +
8 12 - read_multi optimization, now checks local_cache [chendo, #306]
9 13 - Re-implement get_multi to be non-blocking [tmm1, #295]
10 14 - Add `dalli` accessor to dalli_store to access the underlying
7 lib/dalli/client.rb
@@ -340,19 +340,18 @@ def validate_key(key)
340 340 raise ArgumentError, "key cannot be blank" if !key || key.length == 0
341 341 key = key_with_namespace(key)
342 342 if key.length > 250
343   - namespace_length = namespace ? namespace.size : 0
344   - max_length_before_namespace = 212 - namespace_length
  343 + max_length_before_namespace = 212 - (namespace || '').size
345 344 key = "#{key[0, max_length_before_namespace]}:md5:#{Digest::MD5.hexdigest(key)}"
346 345 end
347 346 return key
348 347 end
349 348
350 349 def key_with_namespace(key)
351   - namespace ? "#{namespace}:#{key}" : key
  350 + (ns = namespace) ? "#{ns}:#{key}" : key
352 351 end
353 352
354 353 def key_without_namespace(key)
355   - namespace ? key.sub(%r(\A#{namespace}:), '') : key
  354 + (ns = namespace) ? key.sub(%r(\A#{ns}:), '') : key
356 355 end
357 356
358 357 def namespace

0 comments on commit 16d29f4

Please sign in to comment.
Something went wrong with that request. Please try again.