Plugin Environment Function clearCacheBy()

public final function clearCacheBy(
$clearByContent = false, $clearByMenu = false, $clearByUser = false, $clearByFile = false, $clearByModuleData = false
)

Summary

This function lets you tell the CMS when any cached copies of your Plugin should be cleared.

Where You Can Use It

From within your init() or showSlot() methods, from Zenario 7.0.0 onwards.

Description

Some editions of the CMS have a page caching feature which stores copies of Content Items in the cache directory. There is also a Plugin caching feature which can store the output of each Plugin individually.

If you have called the allowCaching() function to allow your Plugin to be cached, and something on the site then changes, your Plugin may show out of date information unless the cache is cleared at the correct times.

Even if you don't call this function, the CMS will set two rules as to when your cache should be cleared:

  1. The CMS will clear the cache for your Plugin if there are any changes that could potentially have an effect on the whole site.
  2. The CMS will clear the cache of any Plugin on a Content Item when that Content Item is published, trashed or hidden; or when the published version is changed in any way.

By calling this function you can add extra rules as to when your cache should be cleared.

Parameters

$clearByContent

This rule is triggered when any Content Item is published, trashed or hidden; and also when there are any changes to Categories.

Content Summary Lists, Banners with links to other Content Items, and Meta Data Plugins showing a Content Item's Categories are examples of Plugins with this rule set.

Note that you can set rules conditionally; for example, Banners would not set this rule if they did not link to a Content Item.

$clearByMenu

This rule is triggered when anything in the Menu changes.

Any Menu Plugin would have this rule set.

$clearByUser

This rule is triggered when any User-related data (including Characteristics, Groups and Group memberships) changes.

Any Plugin that displays information on Extranet Users, such as the Comments and Forum Plugins which display Screen Names) would have this rule set.

However a Plugin that displayed information on the currently logged in User, for example the Extranet Profile Plugin, would not need to set this rule, as such a Plugin would not allow itself to be cached if an Extranet User was logged in.

$clearByFile

This rule is triggered when a file is added, updated or deleted in the files table.

Banners that display images or animations, Comments or Forum Plugins that display avatars for Users, and Picture Gallery Plugins would have this rule set.

Again note that you can set rules conditionally; for example, Banners would not set this rule if they did not display an image or an animation.

$clearByModuleData

This rule is triggered when any table created by a Module is changed.

For example, the Forum Module creates tables that store forum posts. The cache for the Forum should be cleared if someone adds a post, so the Forum Plugin would have this rule set.

Examples

$this->allowCaching(
$clearByContent = true, $clearByMenu = true, $clearByUser = true,
$clearByFile = true, $clearByModuleData = true);

Clear the cache when any clearing rule is met.

$this->allowCaching(
$clearByContent = true, $clearByMenu = false, $clearByUser = true,
$clearByFile = false, $clearByModuleData = true);

Clear the cache on specific rules.