I need to store data between different users (thus different sessions) into RAM to speed up web application written in PHP (database and filesystem are not an option).
I have been googling for couple of days, without any luck. I heard about memcached and apc but I don’t really know if they are suitable for me or how to even use it.
I also need this data structure to be thread-safe (not to have race conditions and data inconsistency).
Use case:
I have a static factory function getById($id) which returns instance of a class. I need this function to check if instance exists first, and if it does, return it or otherwise create new one populating with data from database.
Memcached is and distribute cache, the data cached on memcached is on the remote server, and Memcached provide CAS lock(optimistic lock), you can use it make your thread-safe application:
however, APC is an local cache, it implement through share memory, is it thread-safe or not I don’t known