Sunday 03 February 2008 3:51:56 am
Are API fetches (especially all the ones wrapped around persistent layer) cached and reused somehow within a single request? When carrying out some PHP tasks that require fetching data, I always wonder if I should implement my own caching mechanisms. <b>Example:</b> Let's say, we have an array of 100 objects with user ID references (7 different users). I want to fetch user object for each of the 100 objects. I could simply walk the array and fetch user object each time, which would make 100 times, but in fact, only 7 user fetches are actually necessary. Now, does eZ take care of such recurring fetches? Should I implement my own cache (which is quite easy) or would that be unnecessary work? <b>Code example:</b> $userObjectArray = array();
foreach( $objectList as $object )
{
$userID = $object->ID;
if( !isset( $userObjectArray[$userID] ) )
{
$userObjectArray[$userID] = eZContentObject::fetch( $userID );
}
...
}
--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu
|