RSS
Posted in code
ARTICLE 0 comments
06/21 2010

Drupal and Memoization

Memoization is a way to cache the results of calling a function with a specific set of parameters. This can be very useful in Drupal if you need to call a function that does some kind of complex computation or database queries, but is in a part of the code you don’t want to modify. Here is a function I wrote for a recent project that allows you to utilize this technique:

And here are some examples of how you might use it:

Be warned, however. You only want to do this if you know for sure that you are going to call a function more than once. Otherwise it’s just added overhead with no benefit.

Share

digg reddit facebook twitter google 
  1. Track comments via RSS 2.0 feed. Feel free to post the comment, or trackback from your web site.

    Currently there are no comments related to article "Drupal and Memoization".