RES: RES: Is the add command atomic ?
dormando
dormando at rydia.net
Wed Mar 26 22:30:48 UTC 2008
Fausto Richetti Blanco wrote:
> Thanks for your help
>
> I have only one more question :)
>
> If I have the code below:
>
> memcached_create()
>
> If $mc->add('lock') == true then
>
> ... do something ...
>
> $mc->remove('lock')
>
> End if
>
> memcached_free() // this closes the connection to the server
>
> and, unfortunately, my program exits abnormally when it is 'doing
> something'. In this scenario, the key 'lock' will stay in the memcached
> until it gets expired. Is there a way to circumvent this ? e.g.: by
> removing the key 'lock' when the connection to the server is lost ? I
> mean, until you implement more formal locks in memcached ... :)
Nope. That's why you should set the 'lock' key to expire 10-60-100
seconds later. Long enough that it's not possible for the original
process to still be processing after setting the lock. Ghetto locks :)
-Dormando
More information about the memcached
mailing list