I have a system with 2 worker machines which can simultaneously try a job - we do not want both machines to process the job. So, I am thinking of using memcache to cache the ID associated with the job being performed, and if the ID is already present in cache, the machine will not process it. Basically, the idea is that the machine that gets to it first caches it and does the processing, while the second machine should find the id in cache and proceed without processing.
I am using the following command for caching: not_in_progress = Rails.cache.write(id, true, expires_in: 2.minutes, unless_exist: true, raw: true) if not_in_progress *** proceed with the processing *** end My question here is - Is Rails.cache.write atomic? That is, is there ever a situation where both worker machines can come to this statement at the exact same time, not find it in the cache, write it in, get true and proceed for processing? -- --- You received this message because you are subscribed to the Google Groups "memcached" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
