title: Rails Devise: How do I (mem)cache devise's database requests for the user object?
body: <p>Every time I hit an authenticated page, I notice devise issuing an SQL statement :</p>
  
  <p>User Load (0.2ms)  SELECT <code>users</code>.* FROM <code>users</code> WHERE (<code>users</code>.<code>id</code> = 1) LIMIT 1</p>
  
  <p>(I'm using Rails 3 btw .. so cache_money seems out as a solution and despite a lot of searching I've found no substitute).</p>
  
  <p>I tried many overrides in the user model and only find_by_sql seems called. Which gets passed a string of the entire SQL statement.  Something intuitive like find_by_id or find doesn't seem to get called.  I 'can' override this method and glean the user-id and do a reasonable cache system from that - but that's quite ugly.</p>
  
  <p>I also tried overriding authenticate_user which I can intercept one SQL attempt but then calls to current_user seems to try it again.</p>
  
  <p>Simply, my user objects change rarely and its a sad state to keep hitting the db for this instead of a memcache solution. (assume that I'm willing to accept all responsibility for invalidating said cache with :after_save as part but not all of that solution)</p>