Skip to content

Instantly share code, notes, and snippets.

@dkubb
Created July 22, 2008 04:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dkubb/648 to your computer and use it in GitHub Desktop.
Save dkubb/648 to your computer and use it in GitHub Desktop.
# current code:
unless @users = cache_get("active_users")
@users = User.all(:active => true)
cache_set("active_users", @users)
# object caching can be used to avoid pulling huge amounts of data
# from the database.
# you could have calle cache_set with an expiration time as well:
# cache_set("active_users", @users, 10)
end
# my suggestion:
@users = get_cache("active_users") do
User.all(:active => true)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment