
haider
New User
Mar 1, 2002, 10:31 AM
Post #5 of 8
(459 views)
|
|
Re: [PerlKid] How to Perfectly LOCK the database & make it safe ?
[In reply to]
|
Can't Post
|
|
Thanks a lot PerlKid (Philip) but I still need to know: 1) the Fcntl handles the file locking stuff... I think if you look through the rest of that script you'll see that the $flags variable has the locking method used in it. A) >>> If I use fcntl with $flags = O_CREAT | O_RDWR; will it keep the database safely locked untill I enter a untie(%acc); command ? 2) you really don't want to have your entire database loaded into memory unless you have a really good reason. mainly because 99% of the time you are only going to need a small percentage of records and it'd be a waste of time and memory. B) >>> Actually, I want to do something like this: $flag= "read | write"; # not correct format just eg. tie(%acc, 'AnyDBM_File', $db , $flags, 0666) || &error("Cannot open database-- $db"); while ( ($key, $value) = each(%acc) ) { # add 1 to all values $key = "$value + 1"; } untie(%acc); But don't know if it will write all the records back safely and correctly? 4) 1MB or so. some people can get away with larger files but its a real performance loss and fidelity risk C) >>> what do you mean by 1MB ? is it the whole size of the database or only the key+value limits? I want to add about 100-1200 records in that database & hope the limit is not for the whole database size, its only for one 'key+value' length ?... right You should really consider an SQL database system such as MySQL, PostgreSQL, or Oracle. SQL allowes you to simplify your Perl code greatly, and it's much faster and easier to use. D) >>> If the Any_DB system I want to use can take about 2000+ records easily then I will prefer to use it as its very easy & clean but if not I will prefer to use MySql as its available with most hosts but the problem is that I don't understand its coding tricks & I can't find any good free & easy tutorial anywhere ? E) And Can u convert this code to mySql type code that can write the database while updating?: open MySql Connection; # not correct format just Example. while ( ($key, $value) = each(%acc) ) { # add 1 to all values $key = "$value + 1"; } Close MySql connection; # not correct format just Example. Thanks again for your Help, Dear Philip;
|