|
Db::Mediasurface::Cache - caches a specified number of key-value pairs, disgarding underused pairs. |
Db::Mediasurface::Cache - caches a specified number of key-value pairs, disgarding underused pairs.
This document refers to version 0.04 of DB::Mediasurface::Cache, released August 3, 2001.
use Db::Mediasurface::Cache;
my $url = 'http://some.site.com/some/path?version=2';
my $id = undef;
my $cache = Db::Mediasurface::Cache->new( size => 1000 );
unless (defined ($id = $cache->get($url)))
{
$id = urldecode2id($url);
$cache->set($url,$id);
}
Mediasurface relies on retrieving a unique ID for almost every object lookup. This module aims to cache url->id lookups in memory. The module allows commonly used key-value pairs to be stored towards the 'fresh' end of the store, and seldomly used pairs to drift towards the 'stale' end, from where they will eventually be pushed into oblivion, should the cache reach its maximum size. Basically, it's a trade-off between size and speed - the module will perform best when you need to perform lots of lookups of a wide range of urls, but the majority of lookups are contained within a much smaller subset of urls.
set($key,$value)
Nigel Wetters (nwetters@cpan.org)
Copyright (c) 2001, Nigel Wetters. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.
|
Db::Mediasurface::Cache - caches a specified number of key-value pairs, disgarding underused pairs. |