On Mar 25, 9:26 am, gf <[email protected]> wrote:
> Hi, it is primitive implementation. Many threads can repeats one job.
> The best solution is acquiring the mutex, if acquired than we have to
> do the job and write to memcached, else we have to wait untill another
> thread (who acquired) does the job.

  I completely agree with you (except for the part where you believe
memcached to be a lock server).

  If you want to prevent two things from running the same job, you get
a proper lock service to mutually exclude them.

  I have used memcached to optimistically deduplicate jobs (such that
all failure modes lead to running an unnecessary, but harmless job).
If you would like to avoid running the same job more than once, but
it's not harmful if you do (that is, memcached is only an
optimization), then this might be helpful:

  
http://www.rockstarprogrammer.org/post/2008/dec/06/simple-named-job-deduplication/

Reply via email to