object deletion

Steven Grimm sgrimm at facebook.com
Tue Mar 20 15:26:25 UTC 2007


What's the problem you're trying to solve? You want to see why cache 
entries are vanishing, I imagine? If so, then you're right, just logging 
it will be easiest, especially if you have multiple clients. The server 
doesn't do that out of the box, but it'd be pretty easy to hack in. I 
think the following would do it (output will only happen if you run the 
server with "-vv"):

--- a/src/items.c
+++ b/src/items.c
@@ -100,6 +100,8 @@ item *do_item_alloc(char *key, size_t nkey, int 
flags, rel_time_t expti
 
         for (search = tails[id]; tries>0 && search; tries--, 
search=search->prev) {
             if (search->refcount==0) {
+                if (settings.verbose > 1)
+                    printf("evicting item %s\n", ITEM_key(search));
                 do_item_unlink(search);
                 break;
             }

That's against the MT version of the code but should apply to the 
vanilla 1.2.x code too (maybe even 1.1.x).

-Steve


Cristian Rusu wrote:
> Hello
>
> Is there any way to make the server call a specified client API 
> function on object deletion when that happens in order to release 
> resources for new objects? It will be useful at least for debug purposes?
>
> Something I can set as a callback just before using add or set 
> API...to return all keys deleted.
> Or to set a dump file if not....
>
>
> -- 
> Sincerely
> Cristian Rusu
> Web Programmer & Electronic publisher 



More information about the memcached mailing list