#1 Caching with Instance Variables

Learn a quick way to improve performance. Just store the end result of an expensive command in an instance variable!
# application.rb
def current_user
  @current_user ||= User.find(session[:user_id])
end

你可能感兴趣的:(java,performance)