Permalink
Browse files

performance optimization to max_key_length method

Signed-off-by: Chris Wanstrath <chris@ozmm.org>
  • Loading branch information...
1 parent 3e7e0a0 commit 9129e4ac9bfe95c8d2faf78ea7793764c50736af @lovitt lovitt committed with Sep 2, 2008
Showing with 5 additions and 2 deletions.
  1. +5 −2 lib/acts_as_cached/cache_methods.rb
@@ -168,8 +168,11 @@ def cache_namespace
# Memcache-client automatically prepends the namespace, plus a colon, onto keys, so we take that into account for the max key length.
# Rob Sanheim
def max_key_length
- key_size = cache_config[:key_size] || 250
- @max_key_length ||= cache_namespace ? (key_size - cache_namespace.length - 1) : key_size
+ unless @max_key_length
+ key_size = cache_config[:key_size] || 250
+ @max_key_length = cache_namespace ? (key_size - cache_namespace.length - 1) : key_size
+ end
+ @max_key_length
end
def cache_name

0 comments on commit 9129e4a

Please sign in to comment.