I am building an application using PHP. I have a requirement to introduce a locking mechanism across multiple sessions. When one user has locked an entity, any other user sessions should not be able to try updating the same entity. One simple way to implement this lock is to have a lock file (file system). On a first come first serve basis, the first session established gets the lock and after updation, removes the lock. Any other session, if the lock file exists, doesn\'t allow updation.
Is there any other way apart from this approach ? Like in Java/Servlets, we can have a global persistant cache (public static data structure), which can be shared by all servlet objects.
Likewise, is there any mechanism in PHP to create common PHP objects across all HTTP sessions active on a PHP/web server ?
If there is any way, then I can implement a singleton design pattern and that would solve my problem.
Thanks,
Giri