|more useful options|
Concurrent Cache Patternby pileofrogs (Priest)
|on Aug 03, 2012 at 17:08 UTC||Need Help??|
pileofrogs has asked for the
wisdom of the Perl Monks concerning the following question:
I have a script that runs often, is run by lots of different processes, and takes a long time. It is basically testing the environment to see if whatever called it can proceed.
I should be able to cache the results in some way, but I want to make sure I do the caching properly.
There is no "Key" for this cache. All answers are the same. A database is not appropriate, so I need to handle any atomic/concurrency stuff.
This is where it gets more complicated. Do I wait around for whoever has the lock to finish? Do I wait only if the locking process is doing the tests? How do I handle a situation where a locking process has wandered off into oblivion and hasn't released the lock?
I'm on linux and I'm thinking with flock, but I'm open to non-flock ideas.