Skip to content

Instantly share code, notes, and snippets.

@vDubG
Created August 3, 2012 01:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vDubG/3243140 to your computer and use it in GitHub Desktop.
Save vDubG/3243140 to your computer and use it in GitHub Desktop.
def cache_user(userid)
if user = get("current_user_#{userid}")
return user
else
user = User.first(:id => userid)
set("current_user_#{userid}", user, 3600)
return user
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment