|
Posted by ZeldorBlat on 08/10/07 13:30
On Aug 10, 6:52 am, "philm" <gate...@microsoft.com> wrote:
> Asking for direction if possible.
>
> What I would like to be able to do is detect when particular functions are
> called, so as to be able to set up a results cache, and use that instead of
> continual db calls and processing.
>
> Other alternative I suppose, is to look at building in caching in each
> function...
>
> .. in hope ;)
> PhilM
The second way is the way to do it. For instance:
funciton getFoo() {
//try to get foo from the cache
$foo = Cache::fetch('foo');
if($foo == false) {
$foo = ... //code to get foo from the database.
Cache::write('foo', $foo); //put foo in the cache
}
return $foo;
}
Navigation:
[Reply to this message]
|