summaryrefslogtreecommitdiff
path: root/inc/cache.php
diff options
context:
space:
mode:
authorchris <chris@jalakai.co.uk>2006-09-24 22:21:57 +0200
committerchris <chris@jalakai.co.uk>2006-09-24 22:21:57 +0200
commitce6b63d97068e71369bad95e7959d0110717bbfd (patch)
treef496db6a8c3d9e964f902873a3db81c7a1dddf72 /inc/cache.php
parent100a97e3f1501dd634d1e398f564902dcaf2b3fb (diff)
downloadrpg-ce6b63d97068e71369bad95e7959d0110717bbfd.tar.gz
rpg-ce6b63d97068e71369bad95e7959d0110717bbfd.tar.bz2
cache, metadata & purgefile updates
Cache - add dependency for metadata renderer file - check metadata for end of page life, "date valid end". Metadata Renderer - RSS syntax mode now sets rendered page expiry, "date valid end" and includes the feed URL in "relation haspart". Purgefile For all wiki installations the purgefile records the earliest time before which no cache purge (based on data consistency) is required. Cache files older than this time MAY need to be purged. - remove purgeonadd configuration setting darcs-hash:20060924202157-9b6ab-4531e91411c41914eeab2b6a8160c3d46b001cee.gz
Diffstat (limited to 'inc/cache.php')
-rw-r--r--inc/cache.php29
1 files changed, 24 insertions, 5 deletions
diff --git a/inc/cache.php b/inc/cache.php
index ae27f4e9e..767ad8a35 100644
--- a/inc/cache.php
+++ b/inc/cache.php
@@ -36,6 +36,7 @@ class cache {
* @param array $depends array of cache dependencies, support dependecies:
* 'age' => max age of the cache in seconds
* 'files' => cache must be younger than mtime of each file
+ * (nb. dependency passes if file doesn't exist)
*
* @return bool true if cache can be used, false otherwise
*/
@@ -218,14 +219,21 @@ class cache_renderer extends cache_parser {
if (!parent::_useCache()) return false;
- // for wiki pages, check for internal link status changes
+ // for wiki pages, check metadata dependencies
if (isset($this->page)) {
+ $metadata = p_get_metadata($this->page);
- // check the purgefile
+ // page has an expiry time, after which it should be re-rendered (RSS feeds use this)
+ $page_expiry = $metadata['date']['valid']['end'];
+ if (!empty($page_expiry) && (time() > $page_expiry)) return false;
+
+ // check currnent link existence is consistent with cache version
+ // first check the purgefile
// - if the cache is more recent that the purgefile we know no links can have been updated
if ($this->_time < @filemtime($conf['cachedir'].'/purgefile')) {
- $links = p_get_metadata($this->page,"relation references");
+# $links = p_get_metadata($this->page,"relation references");
+ $links = $metadata['relation']['references'];
if (!empty($links)) {
foreach ($links as $id => $exists) {
@@ -242,9 +250,20 @@ class cache_renderer extends cache_parser {
// renderer cache file dependencies ...
$files = array(
- DOKU_INC.'inc/parser/'.$this->mode.'.php', // ... the renderer
+ DOKU_INC.'inc/parser/'.$this->mode.'.php', // ... the renderer
);
- if (isset($this->page)) { $files[] = metaFN($this->page,'.meta'); } // ... the page's own metadata
+
+ // page implies metadata and possibly some other dependencies
+ if (isset($this->page)) {
+ $metafile = metaFN($this->page,'.meta');
+ if (@file_exists($metafile)) {
+ $files[] = $metafile; // ... the page's own metadata
+ $files[] = DOKU_INC.'inc/parser/metadata.php'; // ... the metadata renderer
+ } else {
+ $this->depends['purge'] = true; // ... purging cache will generate metadata
+ return;
+ }
+ }
$this->depends['files'] = !empty($this->depends['files']) ? array_merge($files, $this->depends['files']) : $files;
parent::_addDependencies();