Posted by KeyboardCowboy on March 16, 2010 at 8:03pm
We're working on implementing multiple methods for improving performance on a Drupal 5 platform and I noticed that various user hooks are called repeatedly on each page request. I realized that neither Drupal 5 nor Drupal 6 implement a static caching mechanism for storing complete user objects as they do for storing complete node objects.
I'm sure there is a good reason for this, but I'm having trouble fully understanding why. Can someone help explain to me why this is not done?
Thanks,
Categories: memcached, nodes, performance, static, users
Comments
Check out pressflow, it
Check out pressflow, it contains such a patch, both for D5 and D6.
Thanks. I actually put the
Thanks. I actually put the solution in myself and it has significantly improved the performance. My concern is why it wasn't included in Drupal 5 or 6 core when it seems like such an obvious solution.
Is there a module to do this
Is there a module to do this in core drupal? Or is the patch available that we could apply it ourselves?
-
@foggyperspectiv | foggyperspective.com (blog)
Pressflow does not currently
Pressflow does not currently contain any user object caching. It does implement lazy sessions, which, combined with a proper proxy cache, dramatically cuts down on access to the back-end that would require loading "anonymous" user objects and sessions.
@Dave Strauss I think what's
@Dave Strauss I think what's under discussion here is something a bit different. Let's say during some hook module A calls user_load(array('uid' => 123)) where 123 is not the current user, and then module B also calls user_load(array('uid' => 123)). All that effort is duplicated and is probably unnecessary. This situation is fairly common from what I see. A static variable cache may go a long way here.
--
Dave Hansen-Lange
Director of Technical Strategy, Advomatic.com
Pronouns: he/him/his
There's a merge request for
There's a merge request for pressflow with both static and persistent caching for users at https://code.launchpad.net/~catch-drupal/pressflow/load_cache
Unless I'm missing something,
Unless I'm missing something, user_load static caching actually isn't in pressflow. It is however in the "loadcache" branch that also adds cache tables for users and nodes. I've broken the original patch into a separate module on that branch and submitted a merge request here:
https://code.launchpad.net/~msonnabaum/pressflow/loadcache/+merge/18482
If you're interested in seeing this in pressflow, please try it out and review it!
Also, D7 has static cache for user_load.
You'r right. This is the
You'r right.
This is the patch I used: http://tag1consulting.com/patches/load_cache, and it is indeed not from Pressflow.
It was quite a time ago, sorry I mixed them up.
Looking at the link now, I see they removed their 5.x version of the patch though.