The Caboteria / TWiki Web / TWikiPrefsPrefsCacheDotPm (21 Jan 2008, TWikiContributor)

Package TWiki::Prefs::PrefsCache

The PrefsCache package holds a cache of topics that have been read in, using the TopicPrefs class. These functions manage that cache.

We maintain 2 hashes of values:

As each cache level is built, the values are copied down from the parent cache level. This sounds monstrously inefficient, but in fact perl does this a lot better than doing a multi-level lookup when a value is referenced. This is especially important when many prefs lookups may be done in a session, for example when searching.

ClassMethod new ($prefs,$parent,$type,$web,$topic,$prefix)

Creates a new Prefs object.

If the specified topic is not found, returns an empty object.

ObjectMethod finish ()

Break circular references.

ObjectMethod finalise ($parent)

Finalise preferences in this cache, by freezing any preferences listed in FINALPREFERENCES at their current value.

ObjectMethod loadPrefsFromTopic ($web,$topic,$keyPrefix)

Loads preferences from a topic. All settings loaded are prefixed with the key prefix (default '').

ObjectMethod loadPrefsFromText ($text,$meta,$web,$topic)

Loads preferences from text and optional metadata. All settings loaded are prefixed with the key prefix (default ''). If $meta is defined, then metadata will be taken from that object. Otherwise, $text will be parsed to extract meta-data.

ObjectMethod insert ($type,$key,$val) -> $boolean

Adds a key-value pair of the given type to the object. Type is Set or Local. Callback used for the Prefs::Parser object, or can be used to add arbitrary new entries to a prefs cache.

Note that attempts to redefine final preferences will be ignored.

Returns 1 if the preference was defined, 0 otherwise.

ObjectMethod stringify ($html,\%shown) -> $text

Generate an (HTML if $html) representation of the content of this cache.

Edit | Attach | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Copyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding The Caboteria? Send feedback
Note: Please contribute updates to this topic on TWiki.org at TWiki:TWiki.TWikiPrefsPrefsCacheDotPm.