Fellow monks,

I need to put records into a storage container, and after a certain interval (configurable, some time between now and several days in the future) the record needs to be taken out and an action performed depending on the data it contains (e.g. send an email, update a database or log a message). The records will be relatively small(a few hundred bytes each) but there may be lots of them (up to hundreds of thousands). Records need to be stored persistently, to survive a server reboot or app failure. Records will be added by several independent processes, so the container needs to be accessible concurrently. Once the record has been acted upon it can be removed. The action does not have to take place at the exact time the interval is up, just after it has passed.

If it weren't for the persistency requirement I could run a network daemon which accepts incoming records, places them into a POE::Queue or a Heap and fires events when they are due. As it is, the best solution I can think of is to put records into an RDBMS, index on a field containing the due date/time, regularly query for select * from table where date >= now() and handle all records that are returned. This does not seem so great because it is possible the next query is issued when the last one isn't done dealing with the returned records (also, it'd be good if I could avoid being dependant on an RDBMS). It would seem ideal if I could just continually pop events off a heap, pausing if the next event in line hasn't reached it's due time. Does anyone know of a persistent heap implementation? I found Cache::File::Heap, but that uses DB_File internally and so will read/write the entire file into/from memory on every tie. Or is there a better solution for what I'm trying to achieve?

Thanks in advance for your time and advice


Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -- Brian W. Kernighan

In reply to Persistent timed events by tirwhan

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.