--- trunk/lib/WebPAC/Store.pm 2005/12/05 17:48:00 218 +++ trunk/lib/WebPAC/Store.pm 2005/12/19 20:55:05 299 @@ -14,11 +14,11 @@ =head1 VERSION -Version 0.06 +Version 0.09 =cut -our $VERSION = '0.06'; +our $VERSION = '0.09'; =head1 SYNOPSIS @@ -128,7 +128,7 @@ Retrive from disk one data_structure records usually using field 000 as key - my $ds = $db->load_ds( id => 42, prefix => 'name' ); + my $ds = $db->load_ds( id => 42, prefix => 'name', database => 'ps' ); This function will also perform basic sanity checking on returned data and disable caching if data is corrupted (or changed since last @@ -137,6 +137,9 @@ C is used to differenciate different source input databases which are indexed in same database. +C if B argument which will override database name used when creating +C object (for simple retrival from multiple databases). + Returns hash or undef if cacheing is disabled or unavailable. =cut @@ -161,16 +164,16 @@ $log->logconfess("got hash, but without id") unless (defined($id)); $log->logconfess("got hash, but id [$id] isn't number") unless ($id =~ /^\d+$/); - my $database = $self->{database}; + my $database = $args->{database} || $self->{database}; my $prefix = $args->{prefix} || ''; $log->logconfess("can't find database name") unless ($database); - my $cache_file = "$cache_path/$prefix/$database#$id"; + my $cache_file = "$cache_path/$database/$prefix/$id"; $cache_file =~ s#//#/#go; open(my $fh, '>>', '/tmp/foo'); -print $fh "$cache_file\n"; +print $fh "LOAD $cache_path / $database / $prefix / $id ==> $cache_file\n"; close($fh); $log->debug("using cache_file $cache_file"); @@ -230,9 +233,13 @@ my $prefix = $arg->{prefix} || ''; - my $cache_file = $self->{path} . "/$prefix/$database#" . $arg->{id}; + my $cache_file = $self->{path} . '/' . $prefix . '/'; $cache_file =~ s#//#/#go; + mkpath($cache_file) unless (-d $cache_file); + + $cache_file .= $arg->{id}; + $log->debug("creating storable cache file $cache_file"); return store {