in reply to Append to a busy flat-file db without leaving customer in lurch

Do you need the ads to be displayed in real time? Like ambrus says, you could append ads to a randomly selected file in a certain range, like newads1.dat through newads10.dat, then set up a cron tab to run a utility every so often that goes through the files, merges the records, appends them to the master file, and deletes the newads files (or renames and moves them, just in case). This would eliminate the flock problem (just increase the range on the file numbers until you no longer are losing ads), and would also prevent you having to open each of the separate files every time you wanted to display ads. Even the cron job wouldn't halt your ads, since you wouldn't need all the files locked simultaneously, just the one you were currently loading.

I hope the ads don't need to be editable, once submitted?

  • Comment on Re: Append to a busy flat-file db without leaving customer in lurch

Replies are listed 'Best First'.
Re^2: Append to a busy flat-file db without leaving customer in lurch
by davebaker (Pilgrim) on Jan 24, 2006 at 15:31 UTC
    Yikes, I had forgotten about the extra amount of locking that is generated by users who are editing their entries... I do in fact allow them to edit most of the text of the ad.