How to properly use PHP5 semaphores?
I have this function that tries to read some values from cache. But if value does not exists it should call alternative source API and save new value into the cache. However, server is very overloaded and almost each time when value does not exists more then one requests are created (a lot of API calls) and each of them will store new vale into cache. However, what I want is to be able to call API many times, but only one process/request to be able to store it in cache: function fetch_cache($key, $alternativeSource) { $redis = new Redis(); $redis->pconnect(ENV_REDIS_HOST); $value = $redis->get