This project is not covered by Drupal’s security advisory policy.

The result cache speeds up slow operations by storing function results in a cache table and later, on page execution time, pulling these results from the cache table rather than calculating them.

Function results are refreshed at cron time.

This module is an API only.

Usage:

Where you before called:

$output = myfunc('do', 'something', array('really' => 'slow'));

call now:

$output = resultcache_getresult('myfunc', 'do', 'something', array('really' => 'slow' ));

How it works:

On the first call of the function, the result together with the function name and the function argument as identifier are stored in the cache_result table. All subsequent calls to the function through the resultcache_getresult wrapper pull the result in the cache table rather than calculating the function. On cron time the resultcache module walks through the cache_result table and recalculates all function/argument pairs and stores them again with their result. Function results that were not used in a while get deleted.

I could improve significantly the performance of a couple of sites with heavy tag clouds and stats across huge tables with this module.

Note - you cannot cache functions that do need contextual information not available on cron time (such as the current user) neither is it possible to cache SQL results directly.

Project information

Releases