This shows you the differences between two versions of the page.
en:public:developer:template_system:tags:string:datacache [2013/05/02 15:34] svanderclock created |
en:public:developer:template_system:tags:string:datacache [2015/04/16 16:36] (current) svanderclock [<#datacache>] |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== <#datacache> ====== | ====== <#datacache> ====== | ||
- | Use this tag to cache in memory some data | + | Use this tag to cache data in memory. This is particularly usefull when part of the of the template |
+ | is slow to construct and not change between each request. if you want to ignore the cache, you can | ||
+ | use ak.no_datacache=1 in the http request params or in the cookie. | ||
==== Parameters ==== | ==== Parameters ==== | ||
^ Name ^ Mandatory ^ Description ^ | ^ Name ^ Mandatory ^ Description ^ | ||
- | | <html><span style="color:#008000">Id</span></html> | No | The ID of the section | | + | | <html><span style="color:#008000">Id</span></html> | Yes | The key to use to store/retrieve the content | |
- | | <html><span style="color:#008000">MoveTo</span></html> | No | Instruct to move this section to the section that have ID equal to the value of this parameter | | + | | <html><span style="color:#008000">content</span></html> | Yes | content to cache in memory | |
- | | <html><span style="color:#008000">Body</span></html> | No | The section content | | + | | <html><span style="color:#008000">validity</span></html> | Yes | Expiration time in seconds, 0 mean no delay, if validity is superior to 30 days, engine will use it as a UNIX timestamps for expiration | |
==== Literal ==== | ==== Literal ==== | ||
- | **<#section moveto="head">**..body..**<#endsection>** | + | **<#datacache id=".." validity="...">**..content..**<#enddatacache>** |
==== Example ==== | ==== Example ==== | ||
Line 19: | Line 20: | ||
<code html> | <code html> | ||
- | <html> | + | <#datacache id="MySlowFunctionResult" validity="604800"> |
- | <head> | + | |
- | <#section id='head'></endsection> | + | |
- | </head> | + | |
- | <body> | + | |
- | <#section moveto='head'>This must be in the header</endsection> | + | |
- | </body> | + | |
- | </html> | + | |
+ | <#ASlowFunction> | ||
+ | |||
+ | <#enddatacache> | ||
+ | |||
</code> | </code> | ||
- | The above example will output: | ||
- | |||
- | <code html> | ||
- | |||
- | <html> | ||
- | <head> | ||
- | This must be in the header | ||
- | </head> | ||
- | <body> | ||
- | </body> | ||
- | </html> | ||
- | |||
- | </code> | ||