views:

55

answers:

1

The Google App Engine memcache documentation states that the time parameter of memcache.set() is an "Optional expiration time, either relative number of seconds from current time (up to 1 month), or an absolute Unix epoch time."

So I tried to set a value for 30 days, which according to Google is 2 592 000 seconds.

However, I highly suspect that this value is too high, because the value was set (memcache.set() returned the value True), but a memcache.get() just after always returned None. Reducing this value to 1 728 000 seconds just worked fine/as expected.

I guess that once passed the highest value, the time parameter gets interpreted as an absolute Unix epoch time. That would mean that 2 592 000 seconds got interpreted as "Sat, 31 Jan 1970 00:00:00 GMT", which is obviously a date in the past...

So what is the highest value you can enter that will get interpreted as a number of seconds in the future?

Edit: On the local dev server, 2 592 000 second worked OK, but not on the production servers. I suppose both servers have a different interpretation of the values.

+1  A: 

Your linked Google documentation is oddly imprecise; the actual memcached documentation is more specific, saying the number may not exceed 2,592,000 (30 days of seconds). So in theory, that should have worked, barring implementation issues. (That statement is echoed in the PHP documentation for its memcache stuff.) So according to the memcached docs, your first value should have worked.

I don't suppose 2,591,999 works? The Google doc does say "up to one month", which if you assume 30 days in a month (not a valid assumption) would be up to 2,592,000 (e.g., but not including). That's at odds with the memcached docs, but perhaps there's an implementation difference or something.

T.J. Crowder
Perhaps the downvoter would like to provide some constructive feedback. The question was, effectively, what's the highest non-Epoch time I can provide. The answer, implementation issues aside, is clear from the memcached docs, so I answered with that and linked the docs.
T.J. Crowder