in reply to Databases Stored In memory

You're getting ahead of yourself. Before you try to solve performance problems from databases, you need to get your stuff to use a database. You will probably find that it's fast enough once you do that.

A relational database like PostgreSQL or MySQL is a good eventual goal, but the quickest transition for you would probably be to switch to a dbm file. Use MLDBM::Sync and it will handle all the necessary locking for you.