Caching UserSession.find ?
It seems a new user is fetched from the DB whenever I call UserSession.find (which happens at various points). Is there any reason why UserSession.find can't be cached? I guess there could be a callback after the request ends to wipe the cache.
Here's the code that does it:
class << self
extend ActiveSupport::Memoizable
def controller=(*args)
super
find(:reload)
end
memoize :find
end
Could anyone find an answer to this?
The documentation recommends memoizing this in ApplicationController, which removes the need for a separate caching of UserSession.find in most cases.
def current_user_session
return @current_user_session if defined?(@current_user_session)
@current_user_session = UserSession.find
end
Hello, I'm going through old authlogic issues and seeing what to do with them. This one looks a bit like a usage question and a bit like a feature request.
If this is a feature request, it's still relevant, and you are committed to implementing it, please open a new issue and we can discuss your implementation plan.
If this is a usage question, please ask it on stackoverflow. Unfortunatley, we just don't have enough volunteers to handle usage questions on github. Also, please check the reference documentation. You might find something there that's not in the readme.
Thanks!