[development] RFC: info hook standardization
David Strauss
david at fourkitchens.com
Mon May 19 22:44:25 UTC 2008
That's not really what we're looking for. We're looking for a sort of drupal_reset_info($key) function that forces a reload of the data.
-----Original Message-----
From: "Darrel O'Pry" <darrel.opry at gmail.com>
Date: Mon, 19 May 2008 18:26:47
To:development at drupal.org
Subject: Re: [development] RFC: info hook standardization
On Mon, May 19, 2008 at 3:06 PM, Larry Garfield <larry at garfieldtech.com <mailto:larry at garfieldtech.com> > wrote:
On Mon, 19 May 2008 11:23:02 -0700, Earl Miles <merlin at logrus.com <mailto: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.
More information about the development
mailing list