【问题标题】:how to set the expiry time more than 30 days in memcachedClient set() method如何在 memcachedClient set() 方法中设置过期时间超过 30 天
【发布时间】:2013-08-13 08:54:47
【问题描述】:

有什么方法可以设置memcachedClient set(String key,int exp,Object obj) 方法来存储对象超过30天(2592000秒)。 如果有,请解释一下。

【问题讨论】:

    标签: memcached spymemcached


    【解决方案1】:

    我相信您可以将到期设置为时间戳。

    根据documentation

    过期时间可以设置为 0 到 30 天,即“永不过期”。任何超过 30 天的时间都被解释为 unix 时间戳日期。如果您想在明年 1 月 1 日使对象过期,您可以这样做。

    【讨论】:

    • 我想设置六十天后的到期时间。像 MemcachedClient client1 = new MemcachedClient(new BinaryConnectionFactory(), AddrUtil.getAddresses("172.22.65.111:11211")); .client1.set("key",2*60*60*30*24,"object");但它不起作用..你能帮帮我吗
    • 获取自 1970 年 1 月 1 日以来的当前时间(以秒为单位)(通常您的语言会提供一个 time 函数,以这种整数格式返回当前时间)。然后添加您的 60 天 (time() + 60 * 24 * 3600)。那是时间戳格式的到期日期。
    猜你喜欢
    • 1970-01-01
    • 2019-04-26
    • 1970-01-01
    • 1970-01-01
    • 2011-10-31
    • 2019-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多