memcached Digest, Vol 18, Issue 8

KILLROY killroy at gmail.com
Thu Jan 12 01:16:31 UTC 2006


As I understood from the memcache docs and code deltes were never meant to
be "straight away" but on a "when resources are available" basis.

I do not understand how you expect to use add because it doesn't overwrite
existign keys when you have just deleted them beforehand.

If your code is more like:

ADD
if(condition){
DELETE
}
ADD

you might change it to:

ADD
if(condition){
SET
}else{
ADD
}

To do what you want. How can you not use set instead of delete-add?

SN

On 1/11/06, memcached-request at lists.danga.com <
memcached-request at lists.danga.com> wrote:
>
> Send memcached mailing list submissions to
>        memcached at lists.danga.com
>
> To subscribe or unsubscribe via the World Wide Web, visit
>        http://lists.danga.com/mailman/listinfo/memcached
> or, via email, send a message with subject or body 'help' to
>        memcached-request at lists.danga.com
>
> You can reach the person managing the list at
>        memcached-owner at lists.danga.com
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of memcached digest..."
>
>
> Today's Topics:
>
>   1. Re: Deletes Are Driving Me Crazy (Matthew Glubb)
>   2. Re: Deletes Are Driving Me Crazy (Fabian Thylmann)
>   3. Re: Deletes Are Driving Me Crazy (Matthew Glubb)
>   4. Re: Deletes Are Driving Me Crazy (Jeff Rodenburg)
>   5. Re: Deletes Are Driving Me Crazy (Matthew Glubb)
>   6. Re: Deletes Are Driving Me Crazy (Greg Whalin)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Wed, 11 Jan 2006 12:09:41 +0000
> From: Matthew Glubb <matt at zgroupplc.com>
> Subject: Re: Deletes Are Driving Me Crazy
> To: memcached at lists.danga.com
> Message-ID: <A841A769-B1E8-4C22-B4F7-9A89167DE79B at zgroupplc.com>
> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
>
> Thanks for the reply, but no, that is not want I want. I need to know
> that when I delete an item, it is deleted. I need to be able to use
> add because there are other situations where I want to prevent the
> possibility of overwriting a value. 'add' is a great way to defend
> against that situation.
>
> Matt
>
> On 11 Jan 2006, at 11:39, Fabian Thylmann wrote:
>
> > Hi Matt,
> >
> > what you probably want is
> >
> > set(key, val)
> >
> > which will set a new value for key even if it exists.
> >
> > Fabian
> >
> >
> > Matthew Glubb wrote:
> >
> >> Happy New Year to you all.
> >>
> >> I am sorry if this has been covered before but I have trawled
> >> through  the list archives and cannot find a definitive solution.
> >>
> >> I would really like to know how to:
> >>
> >> add(key, val)
> >> delete(key)
> >> add(key, val)
> >>
> >> Just seems to plain not work (all adds have zero expiration).
> >>
> >> If I:
> >>
> >> add(key, val)
> >> delete(key, 1)
> >> sleep(2)
> >> add(key, val)
> >>
> >> It works.
> >>
> >> Please can someone enlighten me as to how I may immediately delete
> >> a  key and then add a key of the same name? I am using
> >> memcached-1.1.12  & John McCaskey's mcache extension 1.2.0 beta10.
> >>
> >> I noticed in the archives this thread:
> >>
> >> <http://lists.danga.com/pipermail/memcached/2004-July/000688.html>
> >>
> >> This seems to be related to the problem that I am having but my
> >> version of memcached is almost a year later than this so I would
> >> assume that the patch referred to in the thread is included. I'm
> >> going to check that this isn't a problem with John's mcache
> >> extension  but if anyone has a simple answer to my problem I'd
> >> love to hear it.
> >>
> >> Thanks a lot for your help :)
> >>
> >> Matt
> >>
> >>
> >
>
>
>
> 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>
>
>
>
>
>
> ------------------------------
>
> Message: 2
> Date: Wed, 11 Jan 2006 16:03:24 +0100
> From: Fabian Thylmann <fabian at toomuchmedia.com>
> Subject: Re: Deletes Are Driving Me Crazy
> To: Matthew Glubb <matt at zgroupplc.com>
> Cc: memcached at lists.danga.com
> Message-ID: <43C51E3C.8060804 at toomuchmedia.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Could you explain a little bit more what you are trying to do then?
> Maybe you are using memcached in a way it was not designed to be used.
>
> Fabian
>
>
> Matthew Glubb wrote:
>
> > Thanks for the reply, but no, that is not want I want. I need to know
> > that when I delete an item, it is deleted. I need to be able to use
> > add because there are other situations where I want to prevent the
> > possibility of overwriting a value. 'add' is a great way to defend
> > against that situation.
> >
> > Matt
> >
> > On 11 Jan 2006, at 11:39, Fabian Thylmann wrote:
> >
> >> Hi Matt,
> >>
> >> what you probably want is
> >>
> >> set(key, val)
> >>
> >> which will set a new value for key even if it exists.
> >>
> >> Fabian
> >>
> >>
> >> Matthew Glubb wrote:
> >>
> >>> Happy New Year to you all.
> >>>
> >>> I am sorry if this has been covered before but I have trawled
> >>> through  the list archives and cannot find a definitive solution.
> >>>
> >>> I would really like to know how to:
> >>>
> >>> add(key, val)
> >>> delete(key)
> >>> add(key, val)
> >>>
> >>> Just seems to plain not work (all adds have zero expiration).
> >>>
> >>> If I:
> >>>
> >>> add(key, val)
> >>> delete(key, 1)
> >>> sleep(2)
> >>> add(key, val)
> >>>
> >>> It works.
> >>>
> >>> Please can someone enlighten me as to how I may immediately delete
> >>> a  key and then add a key of the same name? I am using
> >>> memcached-1.1.12  & John McCaskey's mcache extension 1.2.0 beta10.
> >>>
> >>> I noticed in the archives this thread:
> >>>
> >>> <http://lists.danga.com/pipermail/memcached/2004-July/000688.html>
> >>>
> >>> This seems to be related to the problem that I am having but my
> >>> version of memcached is almost a year later than this so I would
> >>> assume that the patch referred to in the thread is included. I'm
> >>> going to check that this isn't a problem with John's mcache
> >>> extension  but if anyone has a simple answer to my problem I'd  love
> >>> to hear it.
> >>>
> >>> Thanks a lot for your help :)
> >>>
> >>> Matt
> >>>
> >>>
> >>
> >
> >
> >
> > 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>
> >
> >
> >
> >
> >
>
>
>
> ------------------------------
>
> Message: 3
> Date: Wed, 11 Jan 2006 16:04:04 +0000
> From: Matthew Glubb <matt at zgroupplc.com>
> Subject: Re: Deletes Are Driving Me Crazy
> To: Fabian Thylmann <fabian at toomuchmedia.com>
> Cc: memcached at lists.danga.com
> Message-ID: <ADEC3F04-9F42-48E3-8709-0B3B6525075B at zgroupplc.com>
> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
>
> Hi Fabian,
>
> If you refer to the thread that I quoted in my original mail it was
> accepted as a bug then and a patch was introduced.
>
> I am afraid that, for legal reasons, I am unable to provide you with
> the specific application of memcache in this instance but I can
> assure you that I understand that memcache is not a database, it is a
> cache ;)
>
> I simply wish to be able to delete a key that has a zero expiry
> period and then immediately be able to add a key of the same name.
> The reason that I cannot use set is because if it already exists in
> the cache I do not want to replace the value.
>
> I have just tried the same process with the PECL extension and the
> problem persists. For this reason I am pretty sure that the problem
> is not with the PHP extensions that I have used.
>
> I should note that this problem seems to be sporadic and time based,
> leading me to believe that keys are not necessarily deleted from
> memcache at the moment the request is made.
>
> Thanks a lot for your help on this one. Perhaps I have missed
> something fundamental about memcache regarding deletes, etc?
>
> Regards,
>
> Matt
>
> On 11 Jan 2006, at 15:03, Fabian Thylmann wrote:
>
> > Could you explain a little bit more what you are trying to do then?
> > Maybe you are using memcached in a way it was not designed to be used.
> >
> > Fabian
> >
> >
> > Matthew Glubb wrote:
> >
> >> Thanks for the reply, but no, that is not want I want. I need to
> >> know  that when I delete an item, it is deleted. I need to be able
> >> to use  add because there are other situations where I want to
> >> prevent the  possibility of overwriting a value. 'add' is a great
> >> way to defend  against that situation.
> >>
> >> Matt
> >>
> >> On 11 Jan 2006, at 11:39, Fabian Thylmann wrote:
> >>
> >>> Hi Matt,
> >>>
> >>> what you probably want is
> >>>
> >>> set(key, val)
> >>>
> >>> which will set a new value for key even if it exists.
> >>>
> >>> Fabian
> >>>
> >>>
> >>> Matthew Glubb wrote:
> >>>
> >>>> Happy New Year to you all.
> >>>>
> >>>> I am sorry if this has been covered before but I have trawled
> >>>> through  the list archives and cannot find a definitive solution.
> >>>>
> >>>> I would really like to know how to:
> >>>>
> >>>> add(key, val)
> >>>> delete(key)
> >>>> add(key, val)
> >>>>
> >>>> Just seems to plain not work (all adds have zero expiration).
> >>>>
> >>>> If I:
> >>>>
> >>>> add(key, val)
> >>>> delete(key, 1)
> >>>> sleep(2)
> >>>> add(key, val)
> >>>>
> >>>> It works.
> >>>>
> >>>> Please can someone enlighten me as to how I may immediately
> >>>> delete  a  key and then add a key of the same name? I am using
> >>>> memcached-1.1.12  & John McCaskey's mcache extension 1.2.0 beta10.
> >>>>
> >>>> I noticed in the archives this thread:
> >>>>
> >>>> <http://lists.danga.com/pipermail/memcached/2004-July/000688.html>
> >>>>
> >>>> This seems to be related to the problem that I am having but
> >>>> my   version of memcached is almost a year later than this so I
> >>>> would   assume that the patch referred to in the thread is
> >>>> included. I'm   going to check that this isn't a problem with
> >>>> John's mcache  extension  but if anyone has a simple answer to
> >>>> my problem I'd  love to hear it.
> >>>>
> >>>> Thanks a lot for your help :)
> >>>>
> >>>> Matt
> >>>>
> >>>>
> >>>
> >>
> >>
> >>
> >> 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>
> >>
> >>
> >>
> >>
> >>
> >
>
>
>
> 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>
>
>
>
>
>
> ------------------------------
>
> Message: 4
> Date: Wed, 11 Jan 2006 09:24:48 -0800
> From: Jeff Rodenburg <jeff.rodenburg at gmail.com>
> Subject: Re: Deletes Are Driving Me Crazy
> To: Matthew Glubb <matt at zgroupplc.com>
> Cc: memcached at lists.danga.com
> Message-ID:
>        <50f433360601110924keb90fffya74a7e27bec3cb35 at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> On 1/11/06, Matthew Glubb <matt at zgroupplc.com> wrote:
> >
> > I simply wish to be able to delete a key that has a zero expiry
> > period and then immediately be able to add a key of the same name.
> > The reason that I cannot use set is because if it already exists in
> > the cache I do not want to replace the value.
> >
>
> I have a somewhat similar requirement, but I'm curious about this specific
> approach.  It sounds as if an object may go into the cache with a given
> key,
> but in some scenarios if that key is already in use, that object would use
> a
> different key in the cache.  Is that accurate?
>
> This sound as if you might be using the cache as a queue or something to
> delineate prioritization or ordering.
>
> I know this doesn't resolve the particular add/delete/add scenario, but
> I'm
> curious about the requirements side.
>
> cheers,
> j
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://lists.danga.com/pipermail/memcached/attachments/20060111/811b3acb/attachment.htm
>
> ------------------------------
>
> Message: 5
> Date: Wed, 11 Jan 2006 18:01:02 +0000
> From: Matthew Glubb <matt at zgroupplc.com>
> Subject: Re: Deletes Are Driving Me Crazy
> To: Jeff Rodenburg <jeff.rodenburg at gmail.com>
> Cc: memcached at lists.danga.com
> Message-ID: <05BB7AE9-E314-4DB1-B0CF-37249FD9C349 at zgroupplc.com>
> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
>
> Okay, I guess I can expand a little :)
>
> You are right to guess that I am using memcache as a queue of sorts.
> It's network related.
>
> Each client has a maximum of N key/value pairs in the memcache.
> Multiple, concurrent requests may be arriving from the same client.
> Every client uses the same key prefix for all of there keys ie.
> prefix_[0 to N-1]. If a client tries to overwrite one of those key/
> value pairs once they have been assigned the request is denied, hence
> the requirement for using add rather than set. If a client session
> ends, all N key/value pairs should be deleted. If the same client
> then starts another session they should be able to recreate up to N
> key/value pairs using the same key names but containing different
> values.
>
> I have multiple red hat boxes running lighttpd and load-balanced fast-
> cgi php 5.0.5 modules with John's mcache extension 1.2.0 beta10
> compiled against libmemcache-1.4.0.b9. Memcached is version 1.1.12.
>
> Sometimes it works, sometimes it doesn't. It seems to me that deleted
> keys are not always deleted 'straightaway'.
>
> Matt
>
> On 11 Jan 2006, at 17:24, Jeff Rodenburg wrote:
>
> > On 1/11/06, Matthew Glubb <matt at zgroupplc.com> wrote:
> >>
> >> I simply wish to be able to delete a key that has a zero expiry
> >> period and then immediately be able to add a key of the same name.
> >> The reason that I cannot use set is because if it already exists in
> >> the cache I do not want to replace the value.
> >>
> >
> > I have a somewhat similar requirement, but I'm curious about this
> > specific
> > approach.  It sounds as if an object may go into the cache with a
> > given key,
> > but in some scenarios if that key is already in use, that object
> > would use a
> > different key in the cache.  Is that accurate?
> >
> > This sound as if you might be using the cache as a queue or
> > something to
> > delineate prioritization or ordering.
> >
> > I know this doesn't resolve the particular add/delete/add scenario,
> > but I'm
> > curious about the requirements side.
> >
> > cheers,
> > j
>
>
>
> 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>
>
>
>
>
>
> ------------------------------
>
> Message: 6
> Date: Wed, 11 Jan 2006 13:23:53 -0500
> From: Greg Whalin <gwhalin at meetup.com>
> Subject: Re: Deletes Are Driving Me Crazy
> To: Matthew Glubb <matt at zgroupplc.com>
> Cc: memcached at lists.danga.com
> Message-ID: <43C54D39.3050805 at meetup.com>
> Content-Type: text/plain; charset=UTF-8; format=flowed
>
> This sounds like something already brought up in the list some time back.
>
> http://lists.danga.com/pipermail/memcached/2004-July/thread.html
>
> Check for subj: "Add fails after delete"
>
> Seems it was supposed to have been fixed?
>
> gw
>
> Matthew Glubb wrote:
> > Okay, I guess I can expand a little :)
> >
> > You are right to guess that I am using memcache as a queue of sorts.
> > It's network related.
> >
> > Each client has a maximum of N key/value pairs in the memcache.
> > Multiple, concurrent requests may be arriving from the same client.
> > Every client uses the same key prefix for all of there keys ie.
> > prefix_[0 to N-1]. If a client tries to overwrite one of those key/
> > value pairs once they have been assigned the request is denied, hence
> > the requirement for using add rather than set. If a client session
> > ends, all N key/value pairs should be deleted. If the same client  then
> > starts another session they should be able to recreate up to N
> > key/value pairs using the same key names but containing
> different  values.
> >
> > I have multiple red hat boxes running lighttpd and load-balanced fast-
> > cgi php 5.0.5 modules with John's mcache extension 1.2.0 beta10
> > compiled against libmemcache-1.4.0.b9. Memcached is version 1.1.12.
> >
> > Sometimes it works, sometimes it doesn't. It seems to me that deleted
> > keys are not always deleted 'straightaway'.
> >
> > Matt
> >
> > On 11 Jan 2006, at 17:24, Jeff Rodenburg wrote:
> >
> >> On 1/11/06, Matthew Glubb <matt at zgroupplc.com> wrote:
> >>
> >>>
> >>> I simply wish to be able to delete a key that has a zero expiry
> >>> period and then immediately be able to add a key of the same name.
> >>> The reason that I cannot use set is because if it already exists in
> >>> the cache I do not want to replace the value.
> >>>
> >>
> >> I have a somewhat similar requirement, but I'm curious about this
> >> specific
> >> approach.  It sounds as if an object may go into the cache with a
> >> given key,
> >> but in some scenarios if that key is already in use, that object
> >> would use a
> >> different key in the cache.  Is that accurate?
> >>
> >> This sound as if you might be using the cache as a queue or  something
> to
> >> delineate prioritization or ordering.
> >>
> >> I know this doesn't resolve the particular add/delete/add scenario,
> >> but I'm
> >> curious about the requirements side.
> >>
> >> cheers,
> >> j
> >
> >
> >
> >
> > 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>
> >
> >
> >
>
>
>
> ------------------------------
>
> _______________________________________________
> memcached mailing list
> memcached at lists.danga.com
> http://lists.danga.com/mailman/listinfo/memcached
>
>
> End of memcached Digest, Vol 18, Issue 8
> ****************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.danga.com/pipermail/memcached/attachments/20060112/c705158a/attachment-0001.html


More information about the memcached mailing list