internal package Foswiki::Contrib::DBCacheContrib

See PublishedAPI for packages intended to be used by Plugin and Contrib authors, or browse all packages.
See also Developing plugins, Developer's Bible, Technical Overview

package DBCacheContrib

General purpose cache that presents Foswiki topics as expanded hashes Useful for rapid read and search of the database. Only works on one web.

Typical usage:
  use Foswiki::Contrib::DBCacheContrib;

  $db = new Foswiki::Contrib::DBCacheContrib( $web ); # always done
  $db->load(); # may be always done, or only on demand when a tag is parsed that needs it

  # the DB is a hash of topics keyed on their name
  foreach my $topic ($db->getKeys()) {
     my $attachments = $db->fastget($topic)->fastget("attachments");
     # attachments is an array
     foreach my $val ($attachments->getValues()) {
       my $aname = $attachments->fastget("name");
       my $acomment = $attachments->fastget("comment");
       my $adate = $attachments->fastget("date");
       ...
     }
  }
As topics are loaded, the readTopicLine method gives subclasses an opportunity to apply special processing to indivual lines, for example to extract special syntax such as %ACTION lines, or embedded tables in the text. See FormQueryPlugin for an example of this.

new($web, $cacheName[, $standardSchema ])

Construct a new DBCache object.
  • $web name of web to create the object for.
  • $cacheName name of cache file
  • $standardSchema Set to 1 this will load the cache using the 'standard' Foswiki schema, rather than the original DBCacheContrib extended schema.

readTopicLine($topic, $meta, $line, $lines)

  • $topic - name of the topic being read
  • $meta - reference to the hash object for this topic
  • line - the line being read
  • $lines - reference to array of remaining lines after the current line
The function may modify $lines to cause the caller to skip lines.

onReload($topics)

  • $topics - perl array of topic names that have just been loaded (or reloaded)
Designed to be overridden by subclasses. Called when one or more topics had to be read from disc rather than from the cache. Passed a list of topic names that have been read.

load( [updateCache] ) → ($readFromCache, $readFromFile, $removed)

Load the web into the database. Returns a list containing 3 numbers that give the number of topics read from the cache, the number read from file, and the number of previously cached topics that have been removed.

uptodate($topic, $time) → boolean

Check the file time against what is seen on disc. Return 1 if consistent, 0 if inconsistent.

parseDate($string) → epoch

try as hard as possible to parse the string into epoch seconds

This site is powered by FoswikiCopyright © by the contributing authors. All material on this site is the property of the contributing authors.
Ideas, requests, problems regarding Wasserstoff-Fahrer Forum? Send feedback
This website is using cookies. More info. That's Fine