From 2fc55b7c01c4db4add5792d6deadcd3264f6ca1f Mon Sep 17 00:00:00 2001 From: Adrian Gonzalez Date: Wed, 8 Jul 2015 16:13:49 -0700 Subject: [PATCH] hash long cache keys --- lib/cached_resource/caching.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/cached_resource/caching.rb b/lib/cached_resource/caching.rb index 72fe75d..a0eb457 100644 --- a/lib/cached_resource/caching.rb +++ b/lib/cached_resource/caching.rb @@ -112,7 +112,10 @@ def cache_clear # Generate the request cache key. def cache_key(*arguments) - "#{name.parameterize.gsub("-", "/")}/#{arguments.join('/')}".downcase.delete(' ') + arguments_string = arguments.join('/') + arguments_key = arguments_string.length > 150 ? Digest::SHA2.hexdigest(arguments_string) : arguments_string + + "#{name.parameterize.gsub("-", "/")}/#{arguments_key}".downcase.delete(' ') end # Make a full duplicate of an ActiveResource record.