View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Gergely Nagy > Babble > Babble::Cache



Annotate this POD


New  1
Open  0
View/Report Bugs


Babble::Cache - Caching infrastructure for Babble


This module implements the base Babble::Cache class, one that all other cache modules are based upon. It provides all the methods every module must support. Some of these will only carp - these need to be implemented in subclasses -, some won't have to be touched at all.


Babble::Cache provides the following methods:


new (%params)

Creates a new Babble::Cache object. All parameters passed to it, will be saved for future use. However, the following parameters are recognised by Babble::Cache itself, and are used by the module itself:


The filename of the cache. This is required for proper operation, provided one is using a cache that is loaded from file.

Methods that need subclass implementation

The following methods need to be implemented in subclasses, as they are not generic:

load ()

This just carps, as loading is not supported by the base class.

dump ()

This carps, as saving is not supported by the base class.

get ($category, $id[, $key])

This carps, therefore must be implemented by subclasses.

set ($category, $id, $key, $value)

This carps, therefore must be implemented by subclasses.

Generic methods

frob ($category, $id, $data [, $keys])

Frobnicate stuff in the cache. This is a quite complex method, which does a few interesting things. First, it looks up if an entry named $id exists under the $category in the cache. If it does, all the keys listed in the $keys arrayref will be copied over from the cache. If the cache does not have the key yet, it will be updated. If the entry is not found in the cache, the keys listed in $keys will be stored in it. If $keys is not defined, all keys of $data will be used.

update ($category, $id, $data, $key)

Update the cache with the values of $data when its $key key is defined. Otherwise, return the contents of the appropriate entry of the cache.

cache_fn ([$fn])

Get or set the cache file name.


Gergely Nagy,

Bugs should be reported at


Babble, Babble::Cache::Class::Hash, Babble::Cache::Dumper, Babble::Cache::Storable

syntax highlighting: