Bric::App::Cache

NAME

Bric::App::Cache - Object for managing Application-wide global data.

VERSION

$LastChangedRevision$

DATE

$LastChangedDate$

SYNOPSIS

use Bric::App::Cache;
my $c = Bric::App::Cache->new;
$c = $c->set($key, $val);
my $val = $c->get($key);

my $time = $c->get_lmu_time;
$c = $c->set_lmu_time;

my $site_id = $c->get_user_cx($user_id);
$c = $c->set_user_cx($user_id, $site_id);

DESCRIPTION

This module provides a cache object to cache data that needs to persist across all processes and across all requests, through time and space. The cache is cleared on server restart - for more permenant storage see Bric::Util::DBI.

A Bric::App::Cache object is available from Mason components in the global variable $c.

IMPLEMENTATION

This module is implemented as a two-level cache in order to provide the best possible performance.

The first level is provided by Cache::Mmap. Cache::Mmap is a very fast, shared, file-based cache. However, it is also a fixed-size cache that will drop items from the cache when the cache becomes full or the item to be stored is too large.

When an object cannot be stored in the first-level cache it is passed to the second-level. The second-level cache (also known as a backing store) is provided by Cache::Cache. Cache::Cache is quite a bit slower than Cache::Mmap but has the advantage of being variable-sized. As such it grows dynamically and won't refuse to store an object unless it runs out of disk space.

The get() procedure is:

And the set() prodedure is:

NOTE: Under QA_MODE all set()s are sent to the secondary-cache to allow the cache to be debugged. Cache::Mmap lacks the ability to list all keys in the cache which is used by the QA_MODE code.

INTERFACE

Constructors

Destructors

Public Class Methods

Public Instance Methods

PRIVATE

Private Class Methods

NONE.

Private Instance Methods

NONE.

Private Functions

NOTES

NONE.

AUTHOR

David Wheeler

Sam Tregar

SEE ALSO

Bric, Bric::App::Session, Apache::Session