来自文档:
到期时间可以设置为0,表示"永不过期",为30天.任何高于30天的时间都被解释为unix时间戳日期
因此,要将密钥设置为永不过期,请将超时设置为0.
def _get_memcache_timeout(self, timeout): """ Memcached deals with long (> 30 days) timeouts in a special way. Call this function to obtain a safe value for your timeout. """ timeout = timeout or self.default_timeout if timeout > 2592000: # 60*60*24*30, 30 days # See http://code.google.com/p/memcached/wiki/FAQ # "You can set expire times up to 30 days in the future. After that # memcached interprets it as a date, and will expire the item after # said date. This is a simple (but obscure) mechanic." # # This means that we have to switch to absolute timestamps. timeout += int(time.time()) return timeout
从FAQ:
设置过期时间有哪些限制?(为什么有30天的限制?)
您可以在将来设置最多30天的到期时间.之后,memcached将其解释为日期,并在该日期之后使该项目到期.这是一个简单(但不起眼)的机制.
来自文档:
到期时间可以设置为0,表示"永不过期",为30天.任何高于30天的时间都被解释为unix时间戳日期
因此,要将密钥设置为永不过期,请将超时设置为0.
通过设置在Django 1.6中添加了对非过期缓存的支持timeout=None