[drupal-devel] Drupal cache statistics

Nicholas Ivy nji at njivy.org
Wed Jun 1 16:30:56 UTC 2005

Regardless of cache granularity, we will need to validate and reset the 
cache somehow.  I see two basic methods:

1. An event triggers the cache to reset.  Currently cache_clear_all() 
accomplishes this when we publish nodes, comments, and do certain other 
things.  If we decide to cache page elements, perhaps we could use 
event hooks that module authors can use to trigger cache resets.  The 
challenge is to identify every possible event and consider the 
ramifications of each event for each user, but at least the cache is 
validated only when needed.

2. Page elements poll the cache for every page request.  When a page is 
loaded, the page element computes a cache key and checks for cached 
results.  For example, in nodelist.module I used an md5-checksum of the 
sql query as a cache key.  If the sql query changes, the cache misses.  
In this case, the challenge is to efficiently compute accurate cache 
keys and handle stale results, but at least we don't have to worry 
about every event in the system.

If we used a functional style of programming, Drupal could intercept 
the arguments to certain module functions and check for cached results. 
  But we interact with global dynamic variables (including the 
database), so this is probably not a possibility.

I don't see a way for Drupal to automatically handle caching per page 
element without cooperation from module authors.  So the question is,

1. Do we rely on module authors to hook into every relevant system 
event, or
2. Do we rely on module authors to manage their own cache keys on every 
page load?


On Jun 1, 2005, at 3:04 AM, Dries Buytaert wrote:
> Conclusion
> ----------
> 1. Loose caching has NO effect on drupal.org's page cache.
> 2. Loose caching has NO well-defined effect on drupal.org's flush 
> ratio.
> Possible solutions
> ------------------
> Unless we can serve 2000+ pages/flush (random estimate), the cache 
> will never be efficient.
> 1. Rework loose caching to flush less frequently.
> 2. Flush partially.
> 3. Maybe there is a bug?
> 4. Remove 'loose caching'?
> --
> Dries Buytaert  ::  http://www.buytaert.net/

More information about the drupal-devel mailing list