Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Lock an action for one current use

Hi, I have an action in a controller that should only be called once at a moment.

I thinking of something like a session information, that pretends other users from invoking the action after somebody else already has called it. I cannot use session objects, because they are only accessible for a certain user, but not to all.

After the action has completed it job it should be unlocked so that other users can access it again.

Thank you!

What about user cookies?

A Redis/Beanstalk server could also work, albeit it needs more coding to set up

edited Aug '16

Thank you for your replies

I realised it now by creating a temporary lock file and writing the session ID to it. So everytime a different user wants to invoke the action, I check with an ACL if the lock file exists and if the invoking user has the same session ID as in the lock file or not.

It works fine!

You can also go with libMemcached to store your ACL. But if it's only one locked resource... even file should be enough.

@Ovomaltine85 Well, discussion may be closed?

Thank you for your help!

Discussion can be closed now