Added locking to updatecache.php and updatedb.php