[development] RFC: info hook standardization

Darrel O'Pry darrel.opry at gmail.com
Mon May 19 22:26:47 UTC 2008


On Mon, May 19, 2008 at 3:06 PM, Larry Garfield <larry at garfieldtech.com>
wrote:

>
> On Mon, 19 May 2008 11:23:02 -0700, Earl Miles <merlin at logrus.com> wrote:
> > David Strauss wrote:
> >> Great proposal.
> >>
> >> One addition: a way to invalidate the cache of an info hook if your
> >> info hook does something like reading from a database table. This
> >> would be the case if, say, your module generates a configurable set
> >> of ad blocks.
> >
> > You echoed my issue comment as well. It's very very important to be able
> > to do this easily, IMO.
>
> Ah, indeed!  Make that 2 more attributes of an info hook:
>
> - It has a commonly-named rebuild function: drupal_rebuild_$singularNoun()
> (or something).
> - drupal_rebuild_$singularNoun() is called as part of the master cache
> reset function.
>
> --Larry Garfield
>

but this wouldn't be able to reset a static cache variable? would it? unless
we had something like. I really like to two stage cache for things that
might possibly only want to be cached per request...

function module_invoke_all_cached() {
  static $cache = array();

  $args = func_get_args();
  $hook = $args[0];
  unset($args[0]);
  if (!is_string($hook)) {
    $cache = array();
  }
}

OT: I micro benchmarked { $var = arr[0]; unset($arr[0]); } vs { $var =
array_shift($arr); } and the assign and unset is consistently about 10%-30%
faster.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20080519/d79b205e/attachment.htm 


More information about the development mailing list