{cache-block} implementation again

Author Message

Alexei Pechekhonov

Thursday 05 June 2003 7:05:50 am

{cache-block} looks like very helpful feature, but...
i can't belive in restrictions of using it.I i can use cache-block for includes without errors only:
{cache-block keys=array('search_subscribe',$uri_string)}
{include uri="design/my_site/templates/search_subscribe.tpl"}
{/cache-block}

But when i try make cache for query-arrays - it looks like working and quicker, but i have errors from debugger output:

1. i try to use before {let} statemant, it works, but ....
{cache-block keys=array($current_root, $news_list, $article_list, $event_list, $product_list, $static_list, $DesignKeys:used.node) expiry=28000}
{let
current_root=fetch(content,node,hash(node_id,55))
news_list=fetch(content,tree,hash(parent_node_id,19,limit,5,sort_by,array(published,false()),class_filter_type,include,class_filter_array,array(2,7)))
article_list=fetch(content,tree,hash(parent_node_id,20,limit,5,depth,2,sort_by,array(published,false()),class_filter_type,include,class_filter_array,array(2)))
event_list=fetch(content,tree,hash(parent_node_id,21,limit,5,sort_by,array(published,false()),class_filter_type,include,class_filter_array,array(2,8)))
product_list=fetch(content,tree,hash(parent_node_id,22,limit,5,sort_by,array(published,false()),class_filter_type,include,class_filter_array,array(2,21)))
static_list=fetch(content,list,hash(parent_node_id,55,limit,5,sort_by,$current_root.sort_array ))

}
.... some_page_code....
{/let}
{/cache-block}

debugger says:
Error: eZTemplate
Unknown template variable 'current_root' in namespace ''
Error: eZTemplate
Unknown template variable 'news_list' in namespace ''
Error: eZTemplate
Unknown template variable 'article_list' in namespace ''
Error: eZTemplate
Unknown template variable 'event_list' in namespace ''
Error: eZTemplate
Unknown template variable 'product_list' in namespace ''
Error: eZTemplate
Unknown template variable 'static_list' in namespace ''

because i use the variables before I set them.
Right, but how should i use cache-block for caching queries?
{let $current_root $news_list $article_list $event_list $product_list $static_list}
then
{set current_root = fetch(content,node,hash(node_id,55))}
{set news_list = fetch(content,tree,hash(parent_node_id,19,limit,5,sort_by,array(published,false()),class_filter_type,include,class_filter_array,array(2,7))) }
... etc
Is that? But in this case {set ...} doesn't want to work, because i have 3 namespaces '', 'First' and 'First:Second' and set-construction, say, :
{set article_list=fetch(content, list, hash(parent_node_id, $First:item.node_id, limit, 10, sort_by, $First:item.sort_array, class_filter_type, include, class_filter_array, array(2,13))) }
doesn't work. :(
Q: how should i use cache-block for caching queries?
Did somebody play around? Please ideas...

Bård Farstad

Thursday 05 June 2003 7:16:35 am

What you need to do is to figure out what makes the current block unique. E.g. if you've caching a menue which is the same inside every section you need to make the cache block unique pr section. The uniqueness is decided by the keys of the cache block.

If you have something which is unique pr page ( e.g. the path code ) you could use the request url to make the cache block unique.

Cache blocks will automatically expire when content is published and you can set a timeout.

--bård

Documentation: http://ez.no/doc

Alexei Pechekhonov

Thursday 05 June 2003 9:25:44 am

Thank you, Bard. Now i'm feeling myself more confidence :)
Couldn't you, please, demonstrate your ideas on my example?
Every section on my site has a few lists: menu, line-view, midle-view etc ...
e.g.
loop=list1,
loop=list2,
loop=list3 <--- + some internal loop4
Right? In let/default area i define 3 of them, then i use {set}, but it depends on section, so i need, like you've suggested, to use path/url var ( say $DesignKeys:used.node)for uniquness then cache-block:
{let list1 list2 list3 }
{cache-block keys=array($list1, $list2, $list3, $DesignKeys:used.node}

{set list1=fetch(content,list,hash(parent_node_id, $DesignKeys:used.node ...)}
{set list2=fetch(content,list,hash(parent_node_id, $DesignKeys:used.node ....)}
{set list3=fetch(content,list,hash( parent_node_id, $DesignKeys:used.node ....)}

some_funny_code ...
{section loop=list1 show=....} show_zone1 {/section}
{section loop=list2 show=....} show_zone2 {/section}
{section loop=list3 show=....} show_zone3 ...internal_loop4... {/section}
. . . . . . . . . . . . . . . . . . . . . .
{/cache-block}
{/let}

Yes, the "structure" of lists is the same, but parent_node_id is various from section to section.
Please correct me or share, please, another suitable point of view.

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 14:57:00
Script start
Timing: Jan 18 2025 14:57:00
Module start 'layout'
Timing: Jan 18 2025 14:57:00
Module start 'content'
Timing: Jan 18 2025 14:57:01
Module end 'content'
Timing: Jan 18 2025 14:57:01
Script end

Main resources:

Total runtime0.9617 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.0047 589.3516152.6250
Module start 'layout' 0.00470.0024 741.976639.4453
Module start 'content' 0.00710.9529 781.4219557.0078
Module end 'content' 0.96010.0016 1,338.429712.1563
Script end 0.9616  1,350.5859 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.3354160.0002
Check MTime0.00150.1581160.0001
Mysql Total
Database connection0.00080.080510.0008
Mysqli_queries0.905594.1606570.0159
Looping result0.00050.0550550.0000
Template Total0.934797.220.4673
Template load0.00200.209720.0010
Template processing0.932696.980620.4663
Template load and register function0.00010.012910.0001
states
state_id_array0.00070.069810.0007
state_identifier_array0.00130.136220.0007
Override
Cache load0.00180.1841770.0000
Sytem overhead
Fetch class attribute can translate value0.00060.061820.0003
Fetch class attribute name0.00140.141940.0003
XML
Image XML parsing0.00090.093320.0004
class_abstraction
Instantiating content class attribute0.00000.001140.0000
General
dbfile0.00100.1006170.0001
String conversion0.00000.000740.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/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
8content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 23
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs