2

I am working on django-project ,I want to reduce database request overhead. So I am trying with django-cache (Requires Memcached)

vi /etc/sysconfig/memcached

PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="64" We increased memory size up to 256
OPTIONS="" added IP address "-l 127.0.0.1" 

Changes settings as follows in project:Added new variable in settings.py

CACHE_BACKEND='memcached://localhost:11211'
SESSION_ENGINE = 'django.contrib.sessions.backends.cache'

[ Note : restart memcached: /etc/init.d/memcached restart]

Project is working, It reduces the database request overhead: but that brings certain issues: I lost my session after few time. So I need to login again in application,how can I handle this,I want to store only session details.

Prafull kadam
  • 208
  • 1
  • 6

1 Answers1

1

You are using it correctly but keep in mind that if you restart memcached, you will loose all your existing sessions. That's to be expected.

sorin
  • 161,544
  • 178
  • 535
  • 806
  • Yes, I restart the memcached service after reseting settings, not for every login session, memcached losts data after restart or stop. this is not issue. – Prafull kadam May 31 '16 at 05:34