我在尝试使用 python-memcached 存储大量密钥时发现了一个问题。这是我正在做的事情:
import memcache
# This dict has a 2270 entries that is generated on production server
v = eval(open("/home/dragoon/output").read())
a = memcache.Client(['unix:/tmp/memcached.sock'], debug=1)
接下来我尝试设置所有这些值:
In [94]: len(a.set_multi(v))
MemCached: MemCache: unix:/tmp/memcached.sock: timed out. Marking dead.
Out[94]: 2270
memcached 服务器的日志输出:
...
27: going from conn_new_cmd to conn_parse_cmd
<27 set d750bde63a98579f9c2987907aaaf5f8 1 0 18
27: going from conn_parse_cmd to conn_nread
> FOUND KEY d750bde63a98579f9c2987907aaaf5f8
>27 STORED
27: going from conn_nread to conn_write
Failed to write, and not due to blocking: Broken pipe
27: going from conn_write to conn_closing
<27 connection closed.
一段时间后:
In [96]: len(a.set_multi({'test':1}))
Out[96]: 0
In [97]: a.get('test')
Out[97]: 1
默认超时为 3 秒,但将其增加到 100 秒也无济于事,memcached 只是被卡住了。所以,我的问题是,memcache 有什么问题?
我看到人们谈论在其中存储超过 1000 000 个条目,但对我来说它甚至不能存储 2 000 个?