ez.no / ezpublish / documentation / incoming / smart viewcache cleaning system
These documentation pages are no longer maintained. Please visit the new documentation site.
The goal of 'smart viewchache cleaning' (svcs) is to provide flexibility in the cache system when cleaning the viewcache of an objects nodes. It is aimed to extend default behaviour when cleaning cache in specific(site-depended) situations.
If 'svcs' is turned off (default) the caches of all nodes on the system will be cleared if a published object is changed.
Smart viewcache cleaning is available from eZ publish 3.4.2.
When the content of an object is changed the cache of its nodes should be cleared. To determine for which nodes eZPublish should clear the caches, the 'smart viewcache cleaning system'(svcs) is used.
The default behaviour of 'svcs' when an object is changed is to clear the caches of:
- all published nodes of the object
- parent nodes
- nodes of reverse related objects
From 3.5 it will also clear the caches of:
- nodes of objects with the same keywords (if the object has one or more ezkeyword attributes)
The 'extended' behaviour of 'svcs' is served to determine additional node's identifiers. It depends on settings in ini-file and based on 'path_string' attributes of the published nodes.
Thus the input parameter of 'svcs' is the object's identifier and the output is a list of node's identifiers for which cache should be cleared.
Settings are applied to 'extended' behaviour only and can be found in
'viewcache.ini' file in your settings directory.
The ini-file consists of several sections: one common section and sections which describes rules to calculate additional node's indentifiers.
The common section is named 'ViewCacheSettings' and has these options:
Name Value Description -------------------------------------------------------------------------- SmartCacheClear enabled, enables/disables 'svcs'. disabled(default) If disabled then caches for all nodes will be cleared;
Other sections should begin with indentifier of the class for which rule is made.
Allowed options for these sections are:
Name Value Description -------------------------------------------------------------------------- DependentClassIdentifier forum, folder, identifier of the class. article, etc. Caches of the nodes of objects of this class will be cleared if the object for which cache is cleaning now belongs to the class which identifier is pointed as name of this section; this is an array so multiple identifiers can be used; ClearCacheMethod see below for which nodes cache should be cleared(parent, reverse related, etc.); ObjectFilter list of object's if specified then caches of ids these objects only will be cleared. Means 'all objects of this class' if not specified; MaxParents integer(1,...) Specifies the maximum parents to check in node's 'path_string'. Means 'unlimited' if not specified;
'ClearCacheMethod' values:
Name Description -------------------------------------------------------------------------- clear_object_caches_only clear cache for object's nodes only; clear_object_and_parent_nodes_caches clear cache for object's nodes and their parent; clear_object_and_relating_objects_caches clear cache for object's nodes and reverse related objects; clear_parent_nodes_caches_only clear cache for parent nodes; clear_parent_nodes_and_relating_caches clear cache for parent nodes and reverse related objects; clear_relating_caches_only clear cache for reverse related objects; clear_keyword_caches_only clear cache for objects with the same keywords (from 3.5); clear_all_caches clear cache for object's nodes, their parent, reverse related objects and (from 3.5) objects with the same keywords;
Assume that we have a content structure like this:
eZPublish(nodeID = 2, class_identifier = folder) | |-- Forum folder(nodeID = 58, class_identifier = folder) | |-- Interesting forum(nodeID = 59, class_identifier = forum) | |-- Topic 1(nodeID = 60, class_identifier = forum_topic) | | | |-- Reply1(nodeID = 62, class_identifier = forum_reply) | | | |-- Reply2(nodeID = 126, class_identifier = forum_reply) | | | | -- Reply3(nodeID = 127, class_identifier = forum_reply) | |-- Topic 2(nodeID = 61, class_identifier = forum_topic)
Users can add replies to the 'Topic 1'.
By default when 'SmartCacheClear' is enabled and user adds new reply to the
'Topic 1' viewcache of this reply and its parent('Topic 1') will be cleared.
Looks fine.
Assume now that we need to display forum name and number of post in this
forum when viewing 'Forum folder'. By default after adding new reply cache of
'Forum folder' will not be cleared and viewing of 'Forum folder' will display
outdate information. To fix this you can use 'extended' behaviour of 'svcs'.
You need to make a rule: if new 'forum_reply' was added(published) to 'forum'
then clear cache of the parent of the 'forum'. Thus next lines should be added
to 'viewcache.ini' file:
[forum_reply] DependentClassIdentifier[] DependentClassIdentifier[]=forum ClearCacheMethod=clear_parent_nodes_caches_only
So now when new 'forum_reply' object will be published 'svcs' will look to
ini-file, find [forum_reply] section and start to search objects of 'forum'
class in 'path_string' attribute of 'forum_reply' node.
For example, if you'll add 'Reply3' object its node will have 'path_string'
attribute: '/1/2/58/59/60/127'. Using last value in path 'svcs' will
determine class identifier of 'Reply3' and thus will find right section in
ini-file. Then 'svcs' will search for nodes which class identifier is equal
to one of the values in the 'DependentClassIdentifier' variable. Searching of appropriate
nodes occures in reverse order: node with id=60 will be checked first, then
node with id=59, ..., id=2. Node with id=60 does'n belong to 'forum' class,
so its cache will be untouched. Next node has id=59 and it belongs to
'forum' class, so its cache will be cleared. Residuary nodes in the path(58,
2) doesn't belongs to 'forum' class, so their cache will be untouched.
Assumes now that in addition to 'Case 1' we have a folder named 'Common folder'
which is published under 'eZPublish' folder and contains 'Forum folder' as
related object. Since 'Forum folder' cache is cleared when new 'forum_reply'
is published cache of 'Common folder' has to be cleared too. For this purpose
we need to add another rule to ini-file:
[forum] DependentClassIdentifier[] DependentClassIdentifier[]=folder ClearCacheMethod=clear_relating_caches_only MaxParents=1;
Now when new 'forum_reply' object will be created cache of 'Forum folder' will be cleared because of rule for 'forum_reply' class and cache of 'Common folder' will be cleared too because of rule for 'forum' class.
Since the 'path_string' of new reply looks like '/1/2/58/59/60/...', there are two 'folder' nodes in the path: with id=2 and id=58. But we don't need to clear cache for 'eZPublish' folder (nodeID=2). 'MaxParents' variable was used to fix this. In this exapmle it says: don't search 'folder' objects that are more then '1' node away from 'forum' node.
Actually for the 'case 2' we can remove 'rule 1' and 'rule 2' and replace them with rule:
[forum_reply] DependentClassIdentifier[] DependentClassIdentifier[]=folder ClearCacheMethod=clear_object_and_relating_objects_caches MaxParents=3; #If 'Forum folder' has object_id=56 for example then the rule above can be more hard by adding next lines: ObjectFilter[] ObjectFilter[]=56
The lines above restrict the rule to one 'folder' object which has
object_id=56.
Comments
Better examples, please. Wording issues
Marco Zinn
Sunday 07 August 2005 2:51:58 pm
Quoting:
"Assume now that we need to display forum name and number of post in this
forum when viewing 'Forum folder'" I guess, this means "Forum folder" object (an object of the "folder" class). Then, this folder should display a LIST of forums, the latest 5 topics in EACH folder and the number of replies for EACH topic... or what?
In other words: Are we talking about http://ez.no/community/forum or http://ez.no/community/forum/general ?
Why don't you just provide "real-live" examples from ez.no?
Quote: "You need to make a rule: if new 'forum_reply' was added(published) to 'forum' then clear cache of the parent of the 'forum'" . Does 'forum' now refer to the "Forum Folder" or the "Interesting Forum" ? I guess, it's the "interesting forum" node (from reading the next lines).
Quoting again: "Node with id=60 does'n belong to 'forum' class,
so its cache will be untouched." Okay, i understand. But shouldn't the cache of that ("Topic 1") be cleared to? From Dmitri's comments, i guess, the cache of "Topic 1" is cleared due to the "default behaviour of 'svcs'"
Last paragraph: "'rule 1' and 'rule 2'" . What are rules 1 and 2?.
Please provide better examples. Maybe use galleries, which have a more simple setup (folder -> gallery -> image); this is enough to explain the issue.
My current problem: I have a Folder called "my Galleries". The override template for that folder should display the newest galleries or images in galleries (tree fetch). But it does not get updates, when i publish an image within a gallery. How should one set this up?
Per default behaviour, a new/updated image will clear the cache of it's node and it's parent node (the gallery). This works. Now: should i create a rule for that gallery (dependantclass=folder, Maxparents=1)? Will that rule be triggered by the default behaviours clearing of the parent node's cache?
Or should i create a rule for the image (dependantclass=gallery,folder, Maxparents=2). Or should (dependantclass=folder, Maxparents=2) sufficy, as the gallery's cache is cleared anyway? None of this worked for me, btw (Upgraded from 3.5.2 to 3.6.1); now i disabled the view caching for that one node using the override template :(
More info
Marco Zinn
Sunday 07 August 2005 2:27:56 pm
http://ez.no/community/bugs/smart...possible_to_disable_in_3_5_2_and_3_6
Quoting Dmitry:
"If (ViewCaching=enabled and SmartCacheClear=disabled) or (ViewCaching=enabled and SmartCacheClear=enabled and "no rules for SmartCacheClear") then caches of NODE, it's parent, and nodes that has NODE as related object will be cleared.
If(ViewCaching=enabled and SmartCacheClear=enabled and "rules for SmartCacheClear") then caches listed above plus caches calculated using "rules" will be cleared.
There was a bug in 3.5.0/3.5.1: If SmartCacheClear=disabled then ALL view caches were cleared."
This answered ONE of my questions: If i specify rules, does this disabled the default behaviour? Answer: No, rules, are adding new object, for which nodes are cleared. (I guess)
default
Frederik Holljen
Tuesday 16 November 2004 11:17:52 am
- all published nodes of the object
- parent nodes
- nodes of reverse related objects
3.4.2 default setting?
Paul Forsyth
Thursday 21 October 2004 6:11:42 pm
paul