2011/4/7 Bluntcoder <mik...@gmail.com>:
> Hello,
>
> I'm trying to write a tool that will show all the data inside
> memcached, including expiry times of the keys. However I have run into
Well, I make a tool for the same purpose as well (
http://www.cnblogs.com/sunyongyue/archive/2011/04/01/memcached_key_traversal.html
), but then found the fact that 'stats cachedump' has a limit echo
buffer memory up to 2MB and won't be able to return all items if
there is too many.
> that were collected, and the fact the difference keeps on growing, I
> am left to assume that the number in cache dump is *not* the expiry
> time, but the time that the key was set.
That base on the version you have, see the source code below.
typedef struct _stritem {
……
rel_time_t time; /* least recent access */
rel_time_t exptime; /* expire time */
……
} item;
// in 1.2.1, use 'least recent access'
len = sprintf(temp, "ITEM %s [%u b; %lu s]\r\n", ITEM_key(it),
it->nbytes - 2, it->time + stats.started);
// in 1.4.5, use 'expire time'
len = snprintf(temp, sizeof(temp), "ITEM %s [%d b; %lu s]\r\n",
key_temp, it->nbytes - 2,
(unsigned long)it->exptime + process_started);
best regards
--
Abioy
2011/4/8 tony Cui <anyone...@gmail.com>:
> Hi All,
> when you put data into the memcached, why there is a time limit. What about
> you do not use the expiration, does it work?
I guess that's the protocol memcached has, and you have to follow the
rules in order to communicate with it, see the text below from
memcached protocol.
"
- <exptime> is expiration time. If it's 0, the item never expires
(although it may be deleted from the cache to make place for other
items). If it's non-zero (either Unix time or offset in seconds from
current time), it is guaranteed that clients will not be able to
retrieve this item after the expiration time arrives (measured by
server time).
"