exptime unclear

Adam Dixon adamtdixon at gmail.com
Wed Dec 20 06:10:38 UTC 2006


Hello all,
I have memcached running for our authentication systems, which hinges
on the UNIX_TIMESTAMP(ExpireDate) which I use to also expire the
memcached record.

What I have found is that, if a record is set, and the timestamp is
already passed the current time, it caches it - and sometimes keeps
it, whereas I would have thought it to dump it straight away as
expired.

I would of thought that this was how it would work? Instead it appears
to have something to do with how long the server has been up.

# perl y.pl 5700
Setting key with exp of 1166588860
The time is now 1166594560 which is -5700 seconds diff.
memcached up for 5662, started at 1166588898 and exptime of -38
Get key ... Gotit.
memcached up 5662sec.
Get key ... Gotit.
.....
memcached up 5667sec.
Get key ... Gotit.
memcached up 5668sec.
Get key ... Gotit.
memcached up 5669sec.
....

Ok so a object that's 5600 seconds old stays in the cache? for how
long I don't know.

# perl y.pl 5600
Setting key with exp of 1166588972
The time is now 1166594572 which is -5600 seconds diff.
memcached up for 5673, started at 1166588898 and exptime of 74
Get key ...DontGotit.
memcached up 5673sec.
Get key ...DontGotit.
.....
memcached up 5676sec.
Get key ...DontGotit.
memcached up 5677sec.
....

This one however is not in the cache, which is to be expected.

Is there pseudo code for this process?
Is this a bug or do I have to change all my application code to
somehow handle this? OR I have it completely wrong.

Kind regards,
Adam


More information about the memcached mailing list