Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

speedup cache_key

  • Loading branch information...
commit d7c869a4039b3adcf89ace8ca83a4f301ff22e03 1 parent 408499c
@lawrencepit lawrencepit authored josevalim committed
Showing with 8 additions and 4 deletions.
  1. +8 −4 lib/i18n/backend/cache.rb
View
12 lib/i18n/backend/cache.rb
@@ -84,11 +84,15 @@ def fetch(cache_key, &block)
def cache_key(locale, key, options)
# This assumes that only simple, native Ruby values are passed to I18n.translate.
- # Also, in Ruby < 1.8.7 {}.hash != {}.hash
- # (see http://paulbarry.com/articles/2009/09/14/why-rails-3-will-require-ruby-1-8-7)
- # If args.inspect does not work for you for some reason, patches are very welcome :)
- ['i18n', I18n.cache_namespace, locale, key.hash, RUBY_VERSION >= "1.8.7" ? options.hash : options.inspect.hash].join('/')
+ "i18n/#{I18n.cache_namespace}/#{locale}/#{key.hash}/#{HASH_HASH ? options.hash : options.inspect.hash}"
end
+
+ private
+ # In Ruby < 1.8.7 {}.hash != {}.hash
+ # (see http://paulbarry.com/articles/2009/09/14/why-rails-3-will-require-ruby-1-8-7)
+ # If options.inspect.hash does not work for you for some reason, patches are very welcome :)
+ HASH_HASH = RUBY_VERSION >= "1.8.7"
+
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.