If you cache much user data, you run the security risk of a session
hijack exploit (to name one). Additionally, these queries tend to be
lightweight and databases optimize for recent queries ... so if the
cost of a query is 1, the cost of 100 queries all exactly alike is
significantly less than 100.
If you really, really want to cache this stuff then do something like
this to your user model:
# This solution has some naivety about your problem. If your user
has_many properties, then you'll have to
# create an array to hold them instead of a nil scalar.
@@_user_properties = nil
@@_user_properties = self.send(user_properties) if
My belief is that doing this will not reduce your server load
meaningfully, and it opens a pretty big security hole.