Skip to content

Commit

Permalink
hash long cache keys
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Gonzalez committed Dec 2, 2015
1 parent 69485ee commit 2fc55b7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/cached_resource/caching.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 2fc55b7

Please sign in to comment.