14 |
|
|
15 |
=head1 VERSION |
=head1 VERSION |
16 |
|
|
17 |
Version 0.06 |
Version 0.09 |
18 |
|
|
19 |
=cut |
=cut |
20 |
|
|
21 |
our $VERSION = '0.06'; |
our $VERSION = '0.09'; |
22 |
|
|
23 |
=head1 SYNOPSIS |
=head1 SYNOPSIS |
24 |
|
|
128 |
|
|
129 |
Retrive from disk one data_structure records usually using field 000 as key |
Retrive from disk one data_structure records usually using field 000 as key |
130 |
|
|
131 |
my $ds = $db->load_ds( id => 42, prefix => 'name' ); |
my $ds = $db->load_ds( id => 42, prefix => 'name', database => 'ps' ); |
132 |
|
|
133 |
This function will also perform basic sanity checking on returned |
This function will also perform basic sanity checking on returned |
134 |
data and disable caching if data is corrupted (or changed since last |
data and disable caching if data is corrupted (or changed since last |
137 |
C<prefix> is used to differenciate different source input databases |
C<prefix> is used to differenciate different source input databases |
138 |
which are indexed in same database. |
which are indexed in same database. |
139 |
|
|
140 |
|
C<database> if B<optional> argument which will override database name used when creating |
141 |
|
C<WebPAC::Store> object (for simple retrival from multiple databases). |
142 |
|
|
143 |
Returns hash or undef if cacheing is disabled or unavailable. |
Returns hash or undef if cacheing is disabled or unavailable. |
144 |
|
|
145 |
=cut |
=cut |
164 |
$log->logconfess("got hash, but without id") unless (defined($id)); |
$log->logconfess("got hash, but without id") unless (defined($id)); |
165 |
$log->logconfess("got hash, but id [$id] isn't number") unless ($id =~ /^\d+$/); |
$log->logconfess("got hash, but id [$id] isn't number") unless ($id =~ /^\d+$/); |
166 |
|
|
167 |
my $database = $self->{database}; |
my $database = $args->{database} || $self->{database}; |
168 |
my $prefix = $args->{prefix} || ''; |
my $prefix = $args->{prefix} || ''; |
169 |
|
|
170 |
$log->logconfess("can't find database name") unless ($database); |
$log->logconfess("can't find database name") unless ($database); |
171 |
|
|
172 |
my $cache_file = "$cache_path/$prefix/$database#$id"; |
my $cache_file = "$cache_path/$database/$prefix/$id"; |
173 |
$cache_file =~ s#//#/#go; |
$cache_file =~ s#//#/#go; |
174 |
|
|
175 |
open(my $fh, '>>', '/tmp/foo'); |
open(my $fh, '>>', '/tmp/foo'); |
176 |
print $fh "$cache_file\n"; |
print $fh "LOAD $cache_path / $database / $prefix / $id ==> $cache_file\n"; |
177 |
close($fh); |
close($fh); |
178 |
|
|
179 |
$log->debug("using cache_file $cache_file"); |
$log->debug("using cache_file $cache_file"); |
233 |
|
|
234 |
my $prefix = $arg->{prefix} || ''; |
my $prefix = $arg->{prefix} || ''; |
235 |
|
|
236 |
my $cache_file = $self->{path} . "/$prefix/$database#" . $arg->{id}; |
my $cache_file = $self->{path} . '/' . $prefix . '/'; |
237 |
$cache_file =~ s#//#/#go; |
$cache_file =~ s#//#/#go; |
238 |
|
|
239 |
|
mkpath($cache_file) unless (-d $cache_file); |
240 |
|
|
241 |
|
$cache_file .= $arg->{id}; |
242 |
|
|
243 |
$log->debug("creating storable cache file $cache_file"); |
$log->debug("creating storable cache file $cache_file"); |
244 |
|
|
245 |
return store { |
return store { |