By default, the value size of a single memcache item is limited to 1MB. How can we increase it?
In the following chapters, we will set the size limit to 10MB.
Edit file /etc/sysconfig/memcached
and add the following line:
OPTIONS="-I 10M"
Then restart memcache service.
If you are using python-memcached
library to access memcache, you need to update your python code.
Before execute python-memcached
's functions, you should update memcache.SERVER_MAX_VALUE_LENGTH
:
import memcache
# update size limit
memcache.SERVER_MAX_VALUE_LENGTH = 1024 * 1024 * 10
# access memcache later
mc = memcache.Client(['127.0.0.1:11211'], debug=0)
mc.set("some_key", "Some value")