For working with Call Logs (Task object) to create and for updating I use OpenCTI and hierarchy custom settings as a cache to keep created TaskId.
I have two methods in Apex Controller: when I get the request to insert/update Task I call Apex method to read custom settings and check: has been task created or not. If Task has been created I load TaskId from custom settings and then update exists Task with Open CTI otherwise I create the new Task. Also, I update my custom settings to keep new TaskId if needed.
All worked fine before I ran into a situation when requests began to arrive very often and my code creates two or more Tasks because the check method doesn't find anything in custom settings.
Obviously this is concurrency issue and I need to lock reading/writing operations to custom settings during the first read/update operation isn't completed.
Now methods in Apex Class are static. Perhaps somebody faced with a similar issue and solved it? How I can solve concurrency issues in my scenario? If it is important I need to save all updates from all requests without missing.