--- trunk/lib/WebPAC/Store.pm 2005/12/19 20:55:05 299 +++ trunk/lib/WebPAC/Store.pm 2006/09/25 18:58:43 710 @@ -10,23 +10,26 @@ =head1 NAME -WebPAC::Store - Store normalized data on disk +WebPAC::Store - Store WebPAC data on disk =head1 VERSION -Version 0.09 +Version 0.10 =cut -our $VERSION = '0.09'; +our $VERSION = '0.10'; =head1 SYNOPSIS -This module provides disk storage for normalised data. +This module provides disk storage for normalised data and lookups. -It is newest component of WebPAC, so it will change quite often or be in -flux. However, I will try to keep backward compatiblity by providing -multiple back-ends. +It is one of newer components of WebPAC, so it will change from time to +time. + +I will try to keep backward compatiblity by providing multiple back-ends, +but this can't be garanteed. In other words, don't delete your input +databases just yet :-) This has additional advantage. I can create single place to plugin other file formats which provide better performance for particular type of data. @@ -62,8 +65,8 @@ sub new { my $class = shift; - my $self = {@_}; - bless($self, $class); + my $self = {@_}; + bless($self, $class); my $log = $self->_get_logger(); @@ -172,10 +175,6 @@ my $cache_file = "$cache_path/$database/$prefix/$id"; $cache_file =~ s#//#/#go; -open(my $fh, '>>', '/tmp/foo'); -print $fh "LOAD $cache_path / $database / $prefix / $id ==> $cache_file\n"; -close($fh); - $log->debug("using cache_file $cache_file"); if (-r $cache_file) { @@ -249,6 +248,34 @@ } +=head2 save_lookup + + $db->save_lookup( $database, $input, $key, $lookup ); + +=cut + +sub save_lookup { + my $self = shift; + my ($database, $input, $key, $lookup) = @_; + + my $log = $self->_get_logger; + + my $path = $self->{'path'} . "/lookup/$input"; + + mkpath($path) unless (-d $path); + + $path .= "/$key"; + + if (store $lookup, $path) { + $log->info("saved lookup $path"); + } else { + $log->logwarn("can't store lookup $database/$input/$key in $path: $!"); + } + + +} + + =head1 AUTHOR Dobrica Pavlinusic, C<< >>