TIM*_*MEX 9 python django memcached
cache.set(key, value, 9999999)
Run Code Online (Sandbox Code Playgroud)
但这不是无限的时间......
mik*_*iku 12
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
Run Code Online (Sandbox Code Playgroud)
从FAQ:
设置过期时间有哪些限制?(为什么有30天的限制?)
您可以在将来设置最多30天的到期时间.之后,memcached将其解释为日期,并在该日期之后使该项目到期.这是一个简单(但不起眼)的机制.
| 归档时间: |
|
| 查看次数: |
9177 次 |
| 最近记录: |