Cache in a module or operator

Author Message

Jérôme Vieilledent

Tuesday 10 February 2009 8:38:37 am

Hi

I would like to know if it was possible to cache content fetched in a module or in a operator, directly in PHP or if it was mandatory to use template for that...

Thanx

André R.

Tuesday 10 February 2009 8:49:15 am

Take a look in the eZTemplateCacheBlock class, its in lib/eztemplate/classes/eztemplatecacheblock.php.
Its a helper class to be able to use cache-blocks directly in php, the file contains several examples of use.

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

Jérôme Vieilledent

Tuesday 10 February 2009 9:18:08 am

Thanks André

I just checked the eZTemplateCacheBlock class. There is an example in the static method <b> eZTemplateCacheBlock::retrieve()</b> :

     list($handler, $data) = eZTemplateCacheBlock::retrieve( array( 'my_cool_key', $id, ), $nodeID, 60 ); // lives 60 seconds
     if ( !$data instanceof eZClusterFileFailure )
     {
         echo $data;
     }
     else
     {
         // ... generate the data
         $data = '...';
         $handler->storeCache( array( 'scope'      => 'template-block',
                                      'binarydata' => $data ) );
     }

But what's the class for <i>$handler</i> in the else section ? I searched in the API doc and I found eZFSFileHandler but the <i>storeCache()</i> method seems to be private.
The doc says : <i>This method is just a continuation of the code in processCache() and is not meant to be called alone since it relies on specific state in the database.</i>
This method is very convenient but will it be still accessible in future releases ?

Thanks

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 22:14:32
Script start
Timing: Jan 18 2025 22:14:32
Module start 'layout'
Timing: Jan 18 2025 22:14:32
Module start 'content'
Timing: Jan 18 2025 22:14:33
Module end 'content'
Timing: Jan 18 2025 22:14:33
Script end

Main resources:

Total runtime0.6377 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0071 589.0313152.6250
Module start 'layout' 0.00710.0024 741.656339.4453
Module start 'content' 0.00950.6265 781.1016549.5078
Module end 'content' 0.63600.0017 1,330.609412.1641
Script end 0.6377  1,342.7734 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.4933160.0002
Check MTime0.00130.2078160.0001
Mysql Total
Database connection0.00100.152910.0010
Mysqli_queries0.582191.2817570.0102
Looping result0.00060.0982550.0000
Template Total0.606495.120.3032
Template load0.00230.368220.0012
Template processing0.604094.715720.3020
Template load and register function0.00010.019110.0001
states
state_id_array0.00130.196810.0013
state_identifier_array0.00110.165320.0005
Override
Cache load0.00190.2995200.0001
Sytem overhead
Fetch class attribute can translate value0.00050.083020.0003
Fetch class attribute name0.00190.293950.0004
XML
Image XML parsing0.00270.428120.0014
class_abstraction
Instantiating content class attribute0.00000.002860.0000
General
dbfile0.00370.5809240.0002
String conversion0.00000.001440.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
4content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 15
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs