CHI is an unified cache interface.
SYNOPSIS
use CHI;
# Choose a standard driver
#
my $cache = CHI->new( driver => 'Memory' );
my $cache = CHI->new( driver => 'File', cache_root => '/path/to/root' );
my $cache = CHI->new(
driver => 'FastMmap',
root_dir => '/path/to/root',
cache_size => '1k'
);
my $cache = CHI->new(
driver => 'Memcached',
servers => [ "10.0.0.15:11211", "10.0.0.15:11212" ]
);
my $cache = CHI->new(
driver => 'Multilevel',
subcaches => [
{ driver => 'Memory' },
{
driver => 'Memcached',
servers => [ "10.0.0.15:11211", "10.0.0.15:11212" ]
}
],
);
# Create your own driver
#
my $cache = CHI->new( driver_class => 'My::Special::Driver' );
# (These drivers coming soon...)
#
my $cache = CHI->new( driver => 'DBI', dbh => $dbh, table => 'app_cache' );
my $cache = CHI->new( driver => 'BerkeleyDB', root_dir => '/path/to/root' );
# Basic cache operations
#
my $customer = $cache->get($name);
if ( !defined $customer ) {
$customer = get_customer_from_db($name);
$cache->set( $name, $customer, "10 minutes" );
}
$cache->remove($name);
CHI provides a unified caching API, designed to assist a developer in persisting data for a specified period of time.
The CHI interface is implemented by driver classes that support fetching, storing and clearing of data. Driver classes exist or will exist for the gamut of storage backends available to Perl, such as memory, plain files, memory mapped files, memcached, and DBI.
CHI is intended as an evolution of DeWitt Clinton's Cache::Cache package, adhering to the basic Cache API but adding new features and addressing limitations in the Cache::Cache implementation.
Product's homepage
Requirements:
· Perl