PerlDoc

26 August 2025 - 17:41 | Version 1 |
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


Parent package: Foswiki::Contrib
Child packages:

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.

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

The function may modify $lines to cause the caller to skip lines.

onReload($topics)

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( [refresh] ) → ($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