0
In [11]: from django.core.cache import cache
In [12]: keys = []
In [13]: for i in range(1, 10000):
...: key = "Key%s" % i
...: value = ("Value%s" % i)*5000
...: cache.set(key, value, None)
...: keys.append(key)
...: # check lost keys
...: lost = 0
...: for k in keys:
...: if not cache.get(k):
...: lost += 1
...: if lost:
...: print "Lost %s in %s" % (lost, i)
我使用Django,與memcached的蟒蛇,用的memcached以下緩存設置:如何將所有項目保存到memcached而不丟失它們?
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': '127.0.0.1:11211',
}
}
對於上述計劃,我開始從i = 1437失去緩存。你能告訴我該怎麼做,我可以保存所有項目緩存?