How can I store a >1MB value via memcached?
<p>At the beginning, I installed <code>memcached 1.4.1</code>, using the parameter <code>-I 2m</code>, but it did not work. Then I installed <code>memcached 1.4.25</code>, and <code>-I 2m</code> still is not working either. In django, <code>cache.set(key,value)</code> when the value size is more than 1 MB, it returns <code>None</code>, and no value is stored in cache.</p>

<p>According to some article, I can store the big value into multi keys, each value less than 1MB, it works. But key management is problematic. </p>

<p>Then I modified the source code <code>memcached.c</code>:</p>

<pre><code>settings.item_size_max = 1024 * 1024; /* The famous 1MB 
</code></pre>

<p>to reflect:</p>

<pre><code>settings.item_size_max = 5 * 1024 * 1024; /* The famous 1MB 
</code></pre>

<p>and after recompiling, it failed again. It still does not store values larger than 1M.</p>

<p>How can I successfully store a >1MB key via <code>memcached</code>?</p>

<p>Versions:</p>

<pre><code>CentOS 7, python 2.7.5, django 1.7
</code></pre>

<blockquote>
  <p>The default maximum object size is 1MB. In memcached 1.4.2 and later,
  you can change the maximum size of an object using the -I command line
  option. For versions before this, to increase this size, you have to
  re-compile memcached. You can modify the value of the POWER_BLOCK
  within the slabs.c file within the source. In memcached 1.4.2 and
  higher, you can configure the maximum supported object size by using
  the -I command-line option. For example, to increase the maximum
  object size to 5MB:</p>

<pre><code>$ memcached -I 5m
</code></pre>
  
  <p>If an object is larger than the maximum object size, you must manually
  split it. memcachedis very simple: you give it a key and some data, it
  tries to cache it in RAM. If you try to store more than the default
  maximum size, the value is just truncated for speed reasons.</p>
</blockquote>