Deletes Are Driving Me Crazy

Matthew Glubb matt at zgroupplc.com
Mon Jan 16 17:18:36 UTC 2006


Okay, deciding to jump in to the world of C I thought that this might  
ensure that deletes are made immediately. I'm not worried about  
expiry times at all so I commented out any checks relating to delete  
delays / expiry times. Can anyone confirm that this will result in  
immediate deletion? All of my unit tests pass :)

Snippet from memcached.c (lines 660->703):

if (strncmp(command, "delete ", 7) == 0) {
         char key[251];
         item *it;
         int res;
         time_t exptime = 0;

         res = sscanf(command, "%*s %250s %ld", key, &exptime);
         it = assoc_find(key);
         if (!it) {
             out_string(c, "NOT_FOUND");
             return;
         }

         //if (exptime == 0) {
             item_unlink(it);
             out_string(c, "DELETED");
             return;
         //}

         if (delcurr >= deltotal) {
             item **new_delete = realloc(todelete, sizeof(item *) *  
deltotal * 2);
             if (new_delete) {
                 todelete = new_delete;
                 deltotal *= 2;
             } else {
                 /*
                  * can't delete it immediately, user wants a delay,
                  * but we ran out of memory for the delete queue
                  */
                 out_string(c, "SERVER_ERROR out of memory");
                 return;
             }
         }

         exptime = realtime(exptime);

         it->refcount++;
         /* use its expiration time as its deletion time now */
         it->exptime = exptime;
         it->it_flags |= ITEM_DELETED;
         todelete[delcurr++] = it;
         out_string(c, "DELETED");
         return;
     }

On 16 Jan 2006, at 17:05, Sean Chittenden wrote:

>> Thanks a lot for the reply. Do you have a version of the code with
>> those changes? My C is non-existent at best :/
>
> I do... if you haven't seen anything by wed, drop me a line to nag and
> I'll get to it (sometimes I drop the ball on this kinda stuff early on
> in the week).  -sc
>
> -- 
> Sean Chittenden



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