Skip to content

Instantly share code, notes, and snippets.

@quamen
Created March 27, 2011 06:33
Show Gist options
  • Select an option

  • Save quamen/888985 to your computer and use it in GitHub Desktop.

Select an option

Save quamen/888985 to your computer and use it in GitHub Desktop.
A read through cache implementation of ActiveResource.find
def find_with_read_through_cache(*arguments)
key = cache_key(arguments)
result = Rails.cache.read(key).try(:dup)
unless result
result = find_without_read_through_cache(*arguments)
Rails.cache.write(key, result)
end
result
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment