Created
March 27, 2011 06:33
-
-
Save quamen/888985 to your computer and use it in GitHub Desktop.
A read through cache implementation of ActiveResource.find
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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