There is plenty of information about locking on this site, try using the search box at the top of the page. My favourite is KM's RE: File Locking, which works for plain files and for DB's which don't have locking capabilities, which I believe include GDB and the likes (and yes, I know if it does not support locking it should not claim to be a DB ;--)
| [reply] |
What DB are you using? Most serious databases will
automatically put locks on data pages so that only one
connection can update a page.
--
<http://www.dave.org.uk>
"Perl makes the fun jobs fun
and the boring jobs bearable" - me
| [reply] |
If your DB doesn't have locking capability, use a locking module. When you need to update a db; create a new one. Lock the new db. When the new db is finished writing to the disk, unlock it and replace the old db with the new db. That way, the old db is safe while the update is being made to the new db.
I hope that helps,
| [reply] |
That depends on exactly what DB you're using. If it's a file based DB (such as the *DBM_File modules), there are methods you can use to lock the entire database - they're all documented in the man page.
If you're using a RDBMS (such as MySQL, Oracle, or PostgreSQL) then you can get away with more fine grained locking, depending on the database. MySQL, for example, only supports table locking, while PostgreSQL supports individual row locking. Check out the docs on whichever server you're using if this is the case. | [reply] |