Deletes Are Driving Me Crazy

Matthew Glubb matt at zgroupplc.com
Thu Jan 12 09:07:16 UTC 2006


I think that you are on to something Skylos. I already use incr to  
provide a simple lock on cache objects. I guess I could just extend  
that lock to cover deletions as well.

Thanks for your Perlisms :)

On 11 Jan 2006, at 19:01, Skylos wrote:

> I dunno the architecture of your application...
>
> But were I doing this in a straightforward way... in a perlish sort  
> of way...
>
> $mc->delete($key,$val);
> unless ($mc->add($key,$val2)) {
>     $mc->replace($key, $val2);
> }
>
> But, if it was something on the order of
>
> Destroy objectinstanceA
> Create objectinstanceB
>
> where the destructor of A deletes, and the creator of B adds, it might
> be alot harder to do that.
>
> In that case, I could see a serious problem regarding this behavior.
>
> Then I start to be hacky.
>
> I'll do something like
>
> sub DESTROY {
>     $mc->add($key . "-okaytoreplace", 1) unless ($mc->incr($key .
> "-okaytoreplace"));
>     $mc->delete($key);
> }
>
> sub new {
>     unless ($mc->add($key, $value)) {
>         unless ($mc->decr($key . "-okaytoreplace")) {
>             $mc->replace($key, $value);
>         } else {
>             error("add failed no overwrite");
>         }
>     }
> }
>
> But... maybe that not work for you.  I dunno.
>
> Just a thought,
>
> Skylos
>
> PS - pardon my perlisms.



m a t t h e w   g l u b b

________________________________________________________________________
Z Group PLC

Tel: +44 (0) 8700 111 173
Fax: +44 (0) 8707 051 393
Txt: +44 (0) 7800 140 877
Web: <http://www.zgroupplc.com/>

PLEASE NOTE ZGROUP IS NOT LIABLE  FOR ANY DAMAGES,  MALFUNCTION, OR LOSS
OF DATA,  CAUSED AS A RESULT OF FOLLOWING  ANY  ADVICE  ENCLOSED IN THIS
EMAIL. ANY CHANGES SHOULD BE CARRIED OUT AT YOUR OWN RISK.

This  email  and  any  files  transmitted  with it are  confidential and
intended solely for the use of the individual or entity to whom they are
addressed.  The opinions  expressed in this mail are those of the author
and do not necessarily  represent the views of the company.  If you have
received this email in error please notify <service at zgroupplc.com>





More information about the memcached mailing list