in reply to A database caching scheme

It's not quite clear to me what your real task is here (if it truly requires a complex query to get, why are you able to cache it?), but I can tell you something about the caching methods you're using. IPC::Shareable is pretty slow, in addition to the semaphores issue you mentioned. For something accessible frlom a cluster of machines, your best options are either MySQL or Cache::Memcached. A simple query against MySQL (single primary key lookup) is extremely fast -- much faster than anything you are likely to write in your own TCP server without a lot of effort. I would suggest you start there, since it's simple to set up and try.