Skip to content

Instantly share code, notes, and snippets.

@benburkert
Forked from dkubb/gist:648
Created July 22, 2008 04:37
Show Gist options
  • Save benburkert/653 to your computer and use it in GitHub Desktop.
Save benburkert/653 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