Python memcached set_multi 存储问题

标签 python memcached python-memcached

我在尝试使用 python-memcached 存储大量 key 时发现了一个问题。 这是我正在做的:

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 个条目,但对我来说它甚至不能存储 2000 个?

最佳答案

尝试使用 pylibmc 作为内存缓存驱动程序,而不是使用 python-memcache

我也在 Ubuntu 11 上的 Memcache 1.4.7 上看到了这个问题。

关于Python memcached set_multi 存储问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7980844/

相关文章:

javascript - Angular.js 中的 Django 表单集等效项

python - 使用python从网络获取url链接

python - 从两个一维向量 a、b 创建 bool 数组 A,如果 a[i]==b[j],则 A[i,j] 为 True

memcached - 无法连接到本地主机上的memcached服务器,如何调试?

ubuntu - 增加 Memcached 最大项目大小

django - django 上的 memcache 不起作用

python - 应用引擎 : Memcache design to ensure fast read and high write throughput

python - Keras function api,手动设置权重到层

php - 是什么原因导致 memcached 错误 10 ('server error' )?

python - 使用 memcached.sock 路径连接到 python-memcached