title: Why Django memcached always return none?
body: <p>I have 2 different cache type as follow: (I am using MySQL connector because the client wants it like this.)</p>
  <pre><code>import os,sys
  from pathlib import Path
  
  sys.path.append(os.path.dirname(os.path.abspath('.')))
  os.environ['DJANGO_SETTINGS_MODULE'] = 'api.settings'
  import django
  django.setup()
  
  
  import mysql.connector
  
  from django.core.cache import cache,caches
  
  
  db_crawl = mysql.connector.connect(
          host=&quot;xx.xx.xx.xx&quot;,
          user=&quot;xxx&quot;,
          password=&quot;xxxx&quot;,
          database=&quot;xxx&quot;
  )
  
  cursor_crawl = db_crawl.cursor(dictionary=True)
  
  def marketprices():
      query = &quot;some query here&quot;
      cursor_crawl.execute(query)
      result = cursor_crawl.fetchall()
      m_cache = caches['marketprice']
      m_cache.set('marketprices', result,1024 * 1024 * 1024)
  </code></pre>
  <p>The query output has about 18 MB cache and I want to hold the cache <code>1024 * 1024 * 1024</code> times.</p>
  <p>My cache settings:</p>
  <pre><code>CACHES = {
      'default': {
          'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
          'LOCATION': BASE_DIR.joinpath('caches'),
          'TIMEOUT':None,
          'OPTIONS': {
              'server_max_value_length': 1024 * 1024 * 1024,
          }
      },
      'marketprice': {
          'BACKEND': 'django.core.cache.backends.memcached.PyMemcacheCache',
          'LOCATION': '127.0.0.1:11211',
          'TIMEOUT':None,
      },
  } 
  
  </code></pre>
  <p>I set and start the Memcached in my server and everything works fine. The <code>service Memcached status</code> is:</p>
  <pre><code>● memcached.service - memcached daemon
       Loaded: loaded (/lib/systemd/system/memcached.service; enabled; vendor preset: enabled)
       Active: active (running) since Mon 2021-07-19 22:33:49 +03; 1h 10min ago
         Docs: man:memcached(1)
     Main PID: 2126782 (memcached)
        Tasks: 10 (limit: 72283)
       Memory: 1.6M
       CGroup: /system.slice/memcached.service
               └─2126782 /usr/bin/memcached -I 256M -m 8192 -p 11211 -u memcache -l 127.0.0.1 -P /var/run/memcached/memcached.pid
  
  Jul 19 22:33:49 vmi552735.contaboserver.net systemd[1]: Started memcached daemon.
  </code></pre>
  <p>However when I try in <code>python manage.py shell</code> the following code every works fine too.</p>
  <pre><code>&gt;&gt; m_cache = caches['marketprice']
  &gt;&gt; m_cache.set(&quot;foo&quot;,&quot;bar&quot;)
  &gt;&gt; m_cache.get('foo')
  &gt;&gt; bar
  </code></pre>
  <p>After running the <code>marketprices</code> function it takes about 2 minutes to finish and there is no error. I also checked the query there is no error at the cursor but when I want to display the output of the following view function:</p>
  <pre><code>m_cache = caches['marketprice']
  datas = m_cache.get('marketprices')
  print(datas[0])
  </code></pre>
  <p>I am getting the error: <code>'NoneType' object is not iterable</code></p>
  <p>I also checked the <code>m_cache.get('marketprices')</code> in <code>manage.py shell</code> nothing return.</p>
  <p>I think Memcached doesn't hold the data in memory what it cause the problem and what is your solution?</p>