Memcached不允许缓存超过1mb限制的项目,即使它已被覆盖

时间:2013-04-06 17:31:14

标签: python caching memcached

使用python-memcached==1.48

终端:

memcached -I 10m

的Python:

Python 2.7.3 (default, Sep 26 2012, 21:51:14) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import memcache
>>> mc = memcache.Client(['127.0.0.1:11211'], debug=0)
>>> print(mc.set('test', ''.join(['a' for x in xrange(1*1024*1024+1)])))
0
>>> print(mc.set('test', ''.join(['a' for x in xrange(1*1024*1024)])))
True

有人可以重现吗?

1 个答案:

答案 0 :(得分:1)

在接受大于1MB的值之前,您必须告诉python-memcache最大值大小是多少:

import memcache

mc = memcache.Client(['127.0.0.1:11211'],
    debug = 0,
    server_max_value_length = 1024*1024*10
)