【发布时间】:2011-02-25 01:37:50
【问题描述】:
在 GAE 中使用 memcache 时,我很少注意到这种奇怪的行为。我在 memcache 中设置了一个值,当我尝试检索相同的值时,我得到 None 而不是原始值。内存缓存值不可能在这么短的时间内过期。当我在 memcache 中设置一个值时,我确实确保返回 True。还有什么可能导致 memcache 值丢失?这是一种常见的系统行为吗?
代码示例:
用于设置值
cache_set = memcache.set(matrix_name+'-'+str(m)+","+str(n),data[n],namespace=uuid)
while cache_set == False :
sleep(0.1)
logging.error(" Cache Set failed. Retrying for %s %s",matrix_name,str[m,n])
cache_set = memcache.set(matrix_name+'-'+str(m)+","+str(n),data[n],namespace=uuid)
用于检索值
memcache.get(matrix_name+'-'+str(m)+","+str(n),namespace=uuid)
【问题讨论】:
-
请您发布设置和检索值的代码吗?
标签: google-app-engine memcached