This page is a considered complete and accurate
. However, if you find an error, please take the time report it
In this short article we are going to learn how to write a simple Cache Provider for ScrewTurn Wiki 3.0 (STW from now on). A Cache Provider is a type of plugin that handles data caching for the purpose of improving performance.
Introduction to Cache Providers
This brief section assumes you have already a general knowledge
on STW providers.
The main tasks a Cache Provider performs are:
- caching page data, both "backend" data (i.e.
PageContent instances) and formatted page content (up to Phase2)
- caching "meta" data, such as the header, footer, etc., up to Phase2
- handling runtime data such as the number of users that are online, what pages are being edited at a given time and page redirections.
Important note: all providers should be totally thread-safe.
Caching of Page Data
The following methods are called by the wiki application for managing page data caching:
SetPageContent sets the content of a page (instance of
GetPageContent gets the content of a page (instance of
PageContent), if any
SetFormattedPageContent sets the Phase2-formatted content of a page (
GetFormattedPageContent gets the Phase2-formatted content of a page (
string), if any
RemovePage removes a page from the page cache
ClearPageContentCache empties the entire page cache
CutCache removes the specified number of least-recently used page items (both
PageContent and formatted content) from the cache
PageCacheUsage (property) returns the number of pages in the page cache (
FormattedPageCacheUsage (property) returns the number of formatted pages in the cache (formatted content).
Caching of Meta Data
The following methods are used by the wiki application for managing "meta" data caching:
GetMetaDataItem gets a meta data item (
string) from the cache, if any
SetMetaDataItem sets a meta data item (
string) in the cache (remove the item if the value is
ClearPseudoCache empties the meta data item cache.
Management of Runtime Data
The following methods are called by the wiki application for managing runtime data:
OnlineUsers (property) gets or sets the number of users that are online
RenewEditingSession is called when a page editing session for a page, user has been started renewed (this information is used to handle concurrent page editing - sessions have a timeout that should be handled by the provider and whose value is specified by the
EditingSessionTimeout system configuration setting)
CancelEditingSession is called when a page editing session for a page, user has been completed
IsPageBeingEdited tells the wiki if a page is being currently edited
WhosEditing tells the wiki who is editing a page
AddRedirection sets the source, destination of a redirection path (used for handling page redirections)
GetRedirectionDestination gets the destination of a redirection, if any
RemovePageFromRedirections removes a page from the redirections data, both from sources and destinations
ClearRedirections empties the redirections data.