Cache Macro

Version 5.1 by Thomas Mortagne on 2011/10/27 18:12

cogCache the content of the macro for some time
Typejavamacro
Category
Developed byUnknown
Rating
0 Votes
LicenseUnknown

Table of contents

Description

Usage

{{cache}}
content to cache here...
{{/cache}}

It's possible to pass an optional id parameter which to use to cache the content. If not defined then the macro will use the content itself as the id. However this doesn't guarantee unicity since the same content could be located on several pages with different results. Also note that the id can contain wiki syntax; this is done so that the user can use script macros to generate the id.

At this point in time it's not possible to configure the time to live (it's hard coded to be 5 minutes) and it's not possible to specify the cache size (it's hardcoded to be 1000 entries - if the cache is full the oldest entry is removed from the cache). This will be improved in the future.

Examples

Force the usage of an id:

{{cache id="myuniqueid"}}
content to cache here...
{{/cache}}

Compute the id based on some script evaluation:

{{velocity}}
#set ($myid="somecomputeduniqueid")
{{/velocity}}

{{cache id="~{~{velocity~}~}$myid~{~{/velocity~}~}"}}
content to cache here...
{{/cache}}

Compute the id based on some URL parameter:

{{cache id="~{~{velocity~}~}$request.id~{~{/velocity~}~}"}}
content to cache here...
{{/cache}}
Tags:
    

Get Connected