On December 14, 2001 03:04 pm, Perrin Harkins wrote: > > So our solution was caching in-process with just a hash, and using a > > DBI/mysql persistent store. > > in pseudo code > > sub get_stuff { > > if (! $cache{$whatever} ) { > > if !( $cache{whatever} = dbi_lookup()) { > > $cache{$whatever}=derive_data_from_original_source($whatever); > > dbi_save($cache_whatever); > > } > > } > > $cache{$whatever} > > } > > That's actually a bit different. That would fail to notice updates between > processes until the in-memory cache was cleared. Still very useful for > read-only data or data that can be out of sync for some period though. > > > The filesystem based / time sensitive aging is a nice little thing we > > should > > > put up in CPAN. We've just not done so yet. > > How does it differ from the other solutions like Cache::FileCache? Is it > something you could add to an existing module? >
Performance,and key structure, semantics. Its mostly different, not better/worse. =pod =head1 NAME UFMEDIA::CacheOneFile - cache a scalar value in a file on disk =head1 SYNOPSIS use UFMEDIA::CacheOneFile; my $cache = new UFMEDIA::CacheOneFile( cache_file => '/var/cache/myapp/flurge.cache', max_age => 30, refill_sub => sub { recalculate_flurges(31337, 'blue', 42) }, ); my $value = $cache->get_value; =head1 DESCRIPTION UFMEDIA::CacheOneFile enables you to cache a single scalar value in a file on disk. Given a filename under a writable directory, a maximum age, and a reference to a refill subroutine, a cache object will cache the result of the refill subroutine in the file the first time B<get_value()> is called, and use the cached value for subsequent calls to B<get_value()> until B<max_age> the cach e file is more than B<max_age> seconds old. If multiple processes share a single cache file, the first process that reads the cache file after it has expired will take responsibility for replacing it with an up-to-date copy. Other processes needing up-to-date information will wait for this to finish and will then use the new value. =head1 AUTHOR Mike Lyons <[EMAIL PROTECTED]> =head1 SEE ALSO perl(1). =cut > - Perrin -- Jay "yohimbe" Thorne [EMAIL PROTECTED] Mgr Sys & Tech, Userfriendly.org