On 23 Nov 2009, at 20:50, lilive wrote:
To be short, my question is :Is it a way to purge the cache for a given page, from the handle method of a syntax plugin ? (the page to remove from the cache is not the page for which the handle method is called)<snip>That's why I'm looking for a way to remove a page from the cache, in the handle method of the dataentry class.
lilive,dokuwiki cache doesn't work by expiring individual pages. Instead it verifies the validity of the cache before using it.
In core dokuwiki, the cached version of page html is dependent on various dokuwiki files (incl. your configuration files and its own metadata), the existence of any pages that are the targets of internal links and the age of the cached copy (that age is shortened drastically if the page contains an RSS feed).
You can extend a page's dependency checking by using an action plugin (the include plugin[*] does this). In your case, I'd guess the data plugin needs to include a list in its metadata of the pages from which it extracts data. Then an action component could add those files to the dependency files array. That is an array of files which must be older than the cache for the cache to be valid.
To expire the cache directly you would need to delete the cached file. This isn't ideal as its possible for plugins to modify the cache name (e.g. the include plugin[*]) in order to cache different versions of a page. There are a couple of short-cuts that will have the same effect.
1. Update the mtime of metadata file. The cached HTML is dependent on the metadata file. If the cache is older than the metadata it won't be valid. You can update metadata by either touching the file or setting some metadata value of your own. This is the best method to use if its only the html that needs to be refreshed - in plugin terms you're calling render() but not handle().
2. Delete the instructions cache. Raw wiki text is converted into render instructions and those instructions are cached (this is the most expensive part of rendering a page). Its possible, but unlikely that any plugin would modify the instruction cache. You can use the same instructions that dokuwiki to get the page's instruction cache object and remove its associated file. But ... if your plugin requires handle() to be called whenever it needs re-rendering its written incorrectly. Anything that needs to be run every time a page needs to be rendered should be in render() allowing the expensive pattern matching process to take place as infrequently as possible.
(Note, you could also touch the raw wiki text. This isn't a good idea as the mtime of this file is important to dokuwiki in other ways).
- Chris[*] Its been a while since I contributed to the include plugin so its behaviour may have changed.