Skip to content

Instantly share code, notes, and snippets.

@DavidQL
Created February 13, 2012 16:05
Show Gist options
  • Save DavidQL/1817882 to your computer and use it in GitHub Desktop.
Save DavidQL/1817882 to your computer and use it in GitHub Desktop.
class User
def eager_load_foo
if Rails.cache.fetch(self.foo_cache_key).nil? # a cache of the current iterator doesn't exist, so create it
Rails.cache.write(self.foo_cache_key, Foo.to_json)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment