flock is a rather general-purpose solution for advisory locks on files. The locking technique can be used for many purposes, but the locks are advisory, and if you use a file lock to signal that a database is in use, that raises the potential for someone using that database to not be aware of an external file that should be checked first. The lock is kind of far away from the resource it is protecting.

By using a database's built-in locks you gain efficiency, and proximity (making it easier to reason about or even know about). A database user outside of your application is more likely to be impeded from doing something destructive in the database if the lock comes from within the database, than if the lock is on a file that is possibly unknown to some consumers of the DB.


Dave


In reply to Re^5: 'flock' with multiple users by davido
in thread 'flock' with multiple users by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.