Skip to content

Instantly share code, notes, and snippets.

@sapienza
Created July 12, 2013 19:28
Show Gist options
  • Select an option

  • Save sapienza/5987088 to your computer and use it in GitHub Desktop.

Select an option

Save sapienza/5987088 to your computer and use it in GitHub Desktop.
Rails and Memcache. Different Cached Scopes for each user.
def self.cached_scope_for_user(user_id)
Rails.cache.fetch "scope_for_user_#{user_id}" do
results = Model.where("user_id = ?)", user_id)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment