27 |
format => 'NULL', |
format => 'NULL', |
28 |
config => $config, |
config => $config, |
29 |
lookup => $lookup_obj, |
lookup => $lookup_obj, |
30 |
|
low_mem => 1, |
31 |
); |
); |
32 |
|
|
33 |
$db->open('/path/to/database'); |
$db->open('/path/to/database'); |
46 |
my $db = new WebPAC::Input( |
my $db = new WebPAC::Input( |
47 |
format => 'NULL' |
format => 'NULL' |
48 |
code_page => 'ISO-8859-2', |
code_page => 'ISO-8859-2', |
49 |
|
low_mem => 1, |
50 |
); |
); |
51 |
|
|
52 |
Optional parametar C<code_page> specify application code page (which will be |
Optional parametar C<code_page> specify application code page (which will be |
53 |
used internally). This should probably be your terminal encoding, and by |
used internally). This should probably be your terminal encoding, and by |
54 |
default, it C<ISO-8859-2>. |
default, it C<ISO-8859-2>. |
55 |
|
|
56 |
|
Default is not to use C<low_mem> options (see L<MEMORY USAGE> below). |
57 |
|
|
58 |
=cut |
=cut |
59 |
|
|
60 |
sub new { |
sub new { |
64 |
|
|
65 |
$self->{'code_page'} ||= 'ISO-8859-2'; |
$self->{'code_page'} ||= 'ISO-8859-2'; |
66 |
|
|
67 |
|
my $log = $self->_get_logger; |
68 |
|
|
69 |
|
# running with low_mem flag? well, use DBM::Deep then. |
70 |
|
if ($self->{'low_mem'}) { |
71 |
|
$log->info("running with low_mem which impacts performance (<32 Mb memory usage)"); |
72 |
|
|
73 |
|
my $db_file = "data.db"; |
74 |
|
|
75 |
|
if (-e $db_file) { |
76 |
|
unlink $db_file or $log->logdie("can't remove '$db_file' from last run"); |
77 |
|
$log->debug("removed '$db_file' from last run"); |
78 |
|
} |
79 |
|
|
80 |
|
require DBM::Deep; |
81 |
|
|
82 |
|
my $db = new DBM::Deep $db_file; |
83 |
|
|
84 |
|
$log->logdie("DBM::Deep error: $!") unless ($db); |
85 |
|
|
86 |
|
if ($db->error()) { |
87 |
|
$log->logdie("can't open '$db_file' under low_mem: ",$db->error()); |
88 |
|
} else { |
89 |
|
$log->debug("using file '$db_file' for DBM::Deep"); |
90 |
|
} |
91 |
|
|
92 |
|
$self->{'db'} = $db; |
93 |
|
} |
94 |
|
|
95 |
$self ? return $self : return undef; |
$self ? return $self : return undef; |
96 |
} |
} |
97 |
|
|