"be consistent" | |
PerlMonks |
Fast database access using DBM::Deep helpby Doozer (Scribe) |
on Aug 07, 2013 at 13:05 UTC ( [id://1048345]=perlquestion: print w/replies, xml ) | Need Help?? |
Doozer has asked for the wisdom of the Perl Monks concerning the following question: Hi guys, I am using DBM::Deep to store some fairly large and complex hashes in databases. I use them to store information for 324 Set Top Boxes. These are separated in to 9 Zones of 36 STBs. In the hash (.db file) each box is a key and the values are a hash of further key/value pairs, for example:
This layout is repeated for all 324 STBs. I have some more databases which store hashes where Groups are defined as the key, and a list of STBs within that group are stored as an array in the value, for example: 'Group 1' => [Z1-B1,Z2-B1,Z3-B1,Z4-B1] We use this information to get data for each STB so that we can control it using IO::Socket::Inet. Sometimes we control groups of STBs at a time, for example sending power on to all STBs in the group "Zone 1". This group would contain 36 STBs. The script iterates through each box in the group, retrieves their control details from the hash database, and then issues commands to them using that data. My problem is that when I choose to control a large number of boxes in one go e.g, the group Zone 1 (36 boxes), I sometimes get an error of "Can't use an undefined value as a symbol reference at my_script.pl line xxx" This error sometimes doesn't happen at all, but when it does, it is not in the same place. The line in the code it refers to is where a connection is made through IO::Socket::Inet. Below is a snippet of my code:
My first thought is that it doesn't retrieve the details needed from the database quick enough to create the IO::Socket::Inet connection. I am currently accessing the database files as follows: tie %controls, 'DBM::Deep', {file => '/var/www/cgi-bin/Database/E2E_STB_Control_Data.db',locking => 1, autoflush => 1, num_txns => 100}; The "num_txns" option was added in to see if it helped but it doesn't. Any ideas or suggestions will be greatly appreciated. Thanks
Back to
Seekers of Perl Wisdom
|
|