Hmmm, this expiration is what I was trying to avoid with my last question :)

Are you planning to implement more formal locks in memcached (when?) or is
this still just an idea ?

Fausto Richetti Blanco
CWI Software - CMMI Nível 2
Desenvolvimento
(51) 3264-3737
http://www.cwi.com.br
-----Mensagem original-----
De: dormando [mailto:[EMAIL PROTECTED] 
Enviada em: quarta-feira, 26 de março de 2008 19:31
Para: Fausto Richetti Blanco
Cc: [email protected]
Assunto: Re: RES: RES: Is the add command atomic ?

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

Reply via email to