Hrmm, while your approach would certainly work, I would hold some concerns as to the scalability of this approach under high server load. From the description of your problem you might do better to look at a caching solution which automatically encompasses this type of object expiry and clean-up - The
Cache modules provide a means to perform just what you require, persistent data with a specific expiry time.
An example of usage which creates a Cache::FileCache cache in /tmp/cgi-data with a default expiry time of 15 minutes and auto-purge set (upon object retrieval) ...
use Cache::FileCache;
my $cache = Cache::FileCache->new({
'cache_root' => '/tmp/cgi-cache',
'default_expires_in' => 900,
'auto_purge_on_get' => 1
});
$cache->set( $key, $data );
.
.
.
$cache->get( $key );
The usage of the Cache modules is relatively straight-forward, incorporating clear and self-explanatory method names, and the provided documentation is excellent. I would strongly recommend having a look at this set of modules as this approach provides you with a pre-built method to implement data persistence with expiry without having to incorporate forking and clean-up within your script.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.