Hello monks,
I'm using the MLDBM module extensively to store persistent data structures that can be shared by different Perl scripts, typically to cache a hash of structs which in turn consist of a bunch of scalars, 3 or 4 arrays and a hash of hashes, eg:
use GDBM_File; use MLDBM qw(GDBM_File Storable); use Thing; ## (Thing is a package) tie (my %hash_db, "MLDBM", 'output.db', &GDBM_WRCREAT, 0606); foreach my $key (keys %hash_db) { my $current_thing = $hash_db{$key}; ## do something with current_thing $hash_db{$key} = $current_thing; } untie %hash_db;
The programs which use MLDBM are maintenance programs in the shell, not web apps. The resulting output files (for about 10,000 keys) are about 10 Mb. All operations, whether read or write, seem to be very fast. My only concern is how MLDBM uses memory. We are using it on a shared hosting plan which limits memory usage, so it is something which we should be aware of.
Does anyone know what actually happens when the MLDBM file is tied to a hash? My guess is that there is some kind of virtual memory scheme in the background, because reading the whole file into memory would not be sensible. It would be nice to know for sure.
Edited by Chady -- code tags.
In reply to MLDBM and Memory by NormalPerson
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |