I agree with your overall assessment -- memcached is supposed to not return 
items whose expiry has passed.

I just built memcached 1.4.15 on my ubuntu box and was able to verify that 
the keys are, as expected, not returned after the expected expiration time 
(in fact, the key is purged from memory on a subsequent get, also as 
expected).

It would help to have a way to reproduce the problem. Is there anything 
you're doing to the key after setting it? You mentioned incremented keys -- 
are you calling incr? Anything else you might be doing?

This is the test I ran:

date +%s; echo -ne "set foo 0 1 5\r\nhello\r\n" | nc localhost 11211; echo 
-ne "get foo\r\n" | nc localhost 11211; echo -ne "stats cachedump 1 0\r\n" 
| nc localhost 11211; sleep 1; echo -ne "get foo\r\n" | nc localhost 11211; 
echo -ne "stats cachedump 1 0\r\n" | nc localhost 11211; date +%s;

Output was as expected:

1390759755
STORED
VALUE foo 0 5
hello
END
ITEM foo [5 b; 1390759755 s]
END
END
END
1390759756

If you could modify the test to fail on your setup, that would be a good 
way to figure out what's going wrong.

~Ryan

On Wednesday, January 22, 2014 6:32:24 PM UTC-8, James Pearson wrote:
>
> We're using memcache to store short-lived, incremented keys for the 
> purposes of rate-limiting.  Right now, we're trying to debug an issue where 
> these keys stick around much longer than we expect.
>
> While investigating the issue, I found an example key that we believe 
> we've set with an expiry time of 300 seconds (five minutes).  Over the 
> course of several hours, I was able to GET it, with the value maintained.
>
> The only way I could figure out to find a key's expiry time (as actually 
> recorded inside memcache) is through the 'stats cachedump' command, like so:
>
>     [$]> (sleep 1; echo "stats cachedump 1 0"; sleep 1; echo "quit";) | 
> telnet localhost 11211 | grep 'my_key'
>     ITEM my_key [2 b; 1389767076 s]
>
> As I understand it[0], that last integer value is the unix timestamp 
> representing the item's expiry time.  That time, however, is roughly one 
> week ago[1].  I double-checked, and the system date is set correctly.
>
> Now, I know that memcached doesn't delete items when they expire, but the 
> protocol explicitly states that I should not be able to get a key if its 
> expiry time has passed[2].  Yet, that appears to be happening.
>
> Given this is a core feature of memcached, my assumption is that this is 
> not, in fact, a bug in memcached, but rather a misunderstanding on my part. 
>  As such, I'd be grateful if you can point out any incorrect assumptions 
> I've made, or provide any advice on where I should be looking.
>
> We're using memcached 1.4.15.
>
> Thanks.
>  - P
>
> [0]: 
> http://stackoverflow.com/q/1645764/120999<http://www.google.com/url?q=http%3A%2F%2Fstackoverflow.com%2Fq%2F1645764%2F120999&sa=D&sntz=1&usg=AFQjCNEveut0SSu7ZuH3J1PfbgNdUjp9XA>
> [1]: https://www.wolframalpha.com/input/?i=1389767076+unixtime
> [2]: 
> https://github.com/memcached/memcached/blob/master/doc/protocol.txt#L165-L168
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"memcached" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to