Logic Tags
Tag appcache


This tag provides caching of data set by data tags. The difference between this tag and the sessioncache tag is that this tag caches data on the application, meaning the data is shared between multiple users, while the sessioncache tag caches data on each user's session where the data is only accessible to each individual user. Typical use of the appcache tag would be to cache data for all users in a Community or a Community page. The sessioncache tag caches data on each user's session.
Note that there is no access control on cached data. Do not cache data tags returning security filtered objects. WCI objects such as Communities, Portlets, or Pages are all secured on a per user basis. Caching security filtered data bypasses security checks and all users using the cached data see the view of the user who happened to add the cache entry.
Also note that most data tags do not need to be cached. Data tags in the ptdata tag library already use server-side cached data. Suitable data tags to cache are ones that execute database or search queries every time they run and where the data is not security filtered. For example custom properties on a Community that every user has access to or a custom list of Communities visible to every user.
To cache a data tag, define it normally and then nest it inside of the cache tag. Then set the data and datascope attributes of the cache tag with the data key and data scope of the data tag. On the cache tag, define expiration duration for the cache entries and a contextid. To cache data in a Community, pass in current Community id as the contextid value. For a page, use the Page id.

Example:
<pt:logic.appcache pt:cachekey="cacheddata" pt:expiration="20" pt:data="datatocache" >
  <pt:custom.customquery pt:key="datatocache"/> // this tag is only run when cached data expired or none is found
</pt:logic.appcache>

<pt:logic.value pt:value="$cacheddata" pt:scope="application"> // accessing the cached data


Tag Information
Tag Nameappcache

Attributes
NameTypeRequiredDefault ValueDescription
cachekeystringfalsenullSpecify a custom entry id. By default the dataid is used as cachekey. A custom cachekey is only needed to prevent cachekey conflicts.
contextidstringfalsenullA value representing a cache context. Examples of contexts are Communities or MyPage/Community pages.To cache data in a Community pass in current Community id as contextid, for a Community Page pass in Page id . It is also possible to combine two or more ids as a contextid to create custom context. For example combining current Community id and Experience Definition id caches data only for users in this Community and Experience Definition. Never use the User id as contextid. Instead, use the logic.sessioncache tag to cache per user.
expirationinttruenullNumber of minutes to cache an entry before rerunning the data tag to refresh the data.
datastringtruenullName of the tag variable where the data tag being cached sets its data. Should be same as the pt:key attribute in the enclosed data tag.
datascopestringfalseportlet requestScope of the data tag variable id.


Copyright 2005 Plumtree Software, Inc.