[development] RFC: info hook standardization

Darrel O'Pry darrel.opry at gmail.com
Mon May 19 16:35:39 UTC 2008


Larry nice proposal. but doesn't module_invoke_all already do basically what
you're describing without the caching and naming enforcement? I agree with
the naming convention, but not the enforcement.

Maybe we just need a module_invoke_all_cacheable($expire, $hook, ....) {
  // expire is same as cache_set, only CACHE_STATIC indicates use a static
var, no db.
  static $cache;
  $cid = $hook .':'. md5(serialize(args));

  // test static cache
  if (!isset($cache[$cid])) {
    // test db cache if necessary, CACHE_STATIC indicates no DB cache
    if ($expires == CACHE_STATIC || !$cache[$cid] =
cache_get('cache_hook_all', $cid))
       $cache[$cid] = module_invoke_all();
    }

    // store to db cache if necessary
    if ($expires != CACHE_STATIC) {
      cache_set('cache_hook_all',....);
    }
 }
 return $cache[$cid])
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20080519/9dac1d30/attachment.htm 


More information about the development mailing list