Forums / Developer / Internal fetch cache/reuse per request?

Internal fetch cache/reuse per request?

Author Message

Piotrek Karaś

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

André R.

Sunday 03 February 2008 4:33:12 am

Objects, classes, sections, class attributes and I also think user object is cached.
They are cached with global variables in the different sections of the kernel.

The core team did test out putting the cache code in persistant object during 3.9 development, but it had too many regressions.

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Piotrek Karaś

Sunday 03 February 2008 4:45:06 am

Thanks a lot, André!
Now I know where to look and in which cases. Naturally, number of SQL queries can be of much help.
Greets,
Piotrek

--
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

eZ debug

Timing: Jan 31 2025 01:16:13
Script start
Timing: Jan 31 2025 01:16:13
Module start 'content'
Timing: Jan 31 2025 01:16:13
Module end 'content'
Timing: Jan 31 2025 01:16:13
Script end

Main resources:

Total runtime0.1862 sec
Peak memory usage8,192.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0066 588.0313370.2891
Module start 'content' 0.00660.0125 958.32031,005.6563
Module end 'content' 0.01900.1672 1,963.97663,894.4922
Script end 0.1862  5,858.4688 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00452.4110200.0002
Check MTime0.00130.7238200.0001
Mysql Total
Database connection0.00060.320510.0006
Mysqli_queries0.091148.89811410.0006
Looping result0.00130.69511390.0000
Template Total0.166789.510.1667
Template load0.00080.455810.0008
Template processing0.165889.040010.1658
Override
Cache load0.00060.305010.0006
Sytem overhead
Fetch class attribute can translate value0.00221.199510.0022
XML
Image XML parsing0.00030.152510.0003
General
dbfile0.00593.1921200.0003
String conversion0.00000.002230.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs