PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, November 13, 2022

[FIXED] How to use memcached in django project?

 November 13, 2022     memcached, python     No comments   

Issue

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.


Solution

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.



Answered By - sorin
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing