[development] Proper way to cache data

William Smith william.darren at gmail.com
Fri May 18 20:58:40 UTC 2007


You can use the base cache table (cache) or make your own by creating a new
table with the same structure.

The cid value doesn't matter -- you make your own (any string).  You'll want
to make it something that you can easily recreate when it comes time to
cache_get the stored data.  So your cid could be something like "foo_" .
$node->nid or whatever.  I usually create a table if I'm going to be caching
a lot of entries.

I'm not sure if there is an existing handbook page detailing how/when the
cache is cleared based on expire argument you pass in, but the api page for
cache_set does have a reasonable overview (
http://api.drupal.org/api/5/function/cache_set)

William

On 5/18/07, Augustin (Beginner) <drupal.beginner at wechange.org> wrote:
>
>
> Hello,
>
> I cannot find in the handbook a tutorial on the proper way to cache data.
>
> A function (http://drupal.org/node/144969) is calculating the values in a
> large array, and I want to serialize the result to be able to cache it on
> the
> database. This way, the array can be made static between requests, for
> better
> performance.
>
> What would be the way to go about it?
> Which {cache_*} table to use, what value to use for cid, etc?
> How often or in what conditions are each of the cache tables emptied?
>
> Is any of the above already documented somewhere?
>
>
> Thanks,
>
> Augustin.
>
>
> --
> http://www.wechange.org/
> Because we and the world need to change.
>
> http://www.reuniting.info/
> Intimate Relationships, peace and harmony in the couple.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20070518/52f73087/attachment.htm 


More information about the development mailing list