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 with python-memcached,缓存设置如下:
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': '127.0.0.1:11211',
}
}在上面的程序中,我开始从i=1437中丢失缓存。你能告诉我怎么做才能将所有的项目保存到缓存中吗?
发布于 2016-10-12 20:34:53
可以通过增加Memcached缓存大小来实现。
https://stackoverflow.com/questions/39998614
复制相似问题