Memcached Object Too Large

memcached

In my memcahced configuration I have

 PORT="11211"                                                                                                                                                                                                                              
 USER="memcached"                                                                                                                                                                                                                          
 MAXCONN="1024"                                                                                                                                                                                                                            
 MAXITEMSIZE=5M                                                                                                                                                                                                                            
 CACHESIZE="12288"                                                                                                                                                                                                                         
 LOGFILE="/var/log/memcached.log"                                                                                                                                                                                                          
 OPTIONS="-vv >> /var/log/memcached 2>&1" 

This is also what I see when I run a stats

STAT limit_maxbytes 67108864

But when I try to write a big item

set test 0 60 5000000 asdas
SERVER_ERROR object too large for cache

Best Answer

Well, the problem is how you star memcached. If you start with init.d based ssytem (like Centos6) you have to check if the /etc/initd./memcached script start the daemon with the -I option. In my case, the -I options was not set in the init script. So:

start () {
...
 daemon --pidfile ${pidfile} memcached -d -p $PORT -u $USER  -m $CACHESIZE -c -I $MAXITEMSIZE $MAXCONN -P ${pidfile} $OPTIONS

Similarly, if your system is based on systemd, like Centos7

[Service]                                                                                                                                                                                                                                 
Type=simple                                                                                                                                                                                                                               
EnvironmentFile=-/etc/sysconfig/memcached                                                                                                                                                                                                 
ExecStart=/usr/bin/memcached -u $USER -p $PORT -I $MAXITEMSIZE -m  $CACHESIZE -c $MAXCONN $OPTIONS