Search code examples
node.jsmemcached

Memcached: How can I modify maximum item size?


I'm newbie in Memcached. By defualt, I know that the minimum item size is 1MB. However, I want to increase this value to 4MB because I've got an item with 2.8MB size.

Following some instructions I have edited my /etc/memcached.conf file and add this entry: -I 4MB

enter image description here

After add this entry, I have saved the file and restart memcached with: sudo service memcached restart

Checking the variable of configuration with this command: echo "stats settings" | nc localhost 11211

I can see that the value of item_size_max setting to 4MB (4194304)

enter image description here

But, If I try to load information in memcached after restart the server, I'v got an error when I try to insert an item with more than 1MB.

enter image description here

What am I doing wrong in my configuration? How can I add items to memcached with more than 1MB of size?

My memcached version is:

enter image description here


Solution

  • The memcached package has a bunch of default props so you need to set the maxValue to 4m too. Passing in an options object when setting up the client will do the job:

    const Memcached = require('memcached');
    const memcached = new Memcached('localhost:11211', {maxValue:4194304});
    

    Or you can do this globally:

    const Memcached = require('memcached');
    Memcached.config.maxValue = 4194304;
    const memcached = new Memcached('localhost:11211');