Gergely Nagy > Babble-0.07 > Babble::Cache

Download:
Babble-0.07.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME ^

Babble::Cache - Caching infrastructure for Babble

DESCRIPTION ^

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.

METHODS ^

Babble::Cache provides the following methods:

Constructor

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:

-cache_fn

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.

AUTHOR ^

Gergely Nagy, algernon@bonehunter.rulez.org

Bugs should be reported at http://bugs.bonehunter.rulez.org/babble.

SEE ALSO ^

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

syntax highlighting: