4

Is there any way to set the memcachedClient set(String key,int exp,Object obj) method to Store object more than 30 days(2592000 second). If any then Explain please.

navin kumar
  • 191
  • 3
  • 6
  • 16

1 Answers1

3

I believe you can set the expiry as a timestamp.

According to the documentation:

Expiration times can be set from 0, meaning "never expire", to 30 days. Any time higher than 30 days is interpreted as a unix timestamp date. If you want to expire an object on january 1st of next year, this is how you do that.

PP.
  • 10,764
  • 7
  • 45
  • 59
  • i want to set the expiry time after sixty days. Like MemcachedClient client1 = new MemcachedClient( new BinaryConnectionFactory(), AddrUtil.getAddresses("172.22.65.111:11211")); .client1.set("key",2*60*60*30*24,"object"); but it doesn't work..can u please help me out – navin kumar Aug 13 '13 at 09:03
  • Get the current time in seconds since 1 January 1970 (usually your language will provide a `time` function that returns the current time in this integer format). Then add your 60 days (`time() + 60 * 24 * 3600`). That is your expiry in timestamp format. – PP. Aug 13 '13 at 09:21