Installing Memcached for Django Application on Windows XP
For a project I needed Memcached. But the problem was that I have my development system on WindowsXP.
When I Google I got various links to install Memcached on windows, but there wasn’t any link that tell all about Memcached with Django on Windows
So Here we go:
Download memcached 1.2.4 Win32.
Unzip the binaries in your desired directory (eg. c:\memcached)
Install the service using the command: ‘c:\memcached\memcached.exe -d install’ from either the command line
Start the server from the Microsoft Management Console or by running the following command: ‘c:\memcached\memcached.exe -d start’
Use the server, by default listening to port 11211
Now we have to get something so that python can talk with our memcached server. For this we have various options, but the easiest is python-memcache
Grap latest file from python-memcached-latest.tar.gz
Extract the compressed files in a directory say C:\python-memcache\
Now Run “python setup.py install”
So till this point the installation part is done. Now the question comes how to use it in Django application.
from django.core.cache import cache
cache_key = 'myID'
result = cache.get(qstr_key)
if result is None:
"""Not Found in Cache"""
data = 'hello'
cache.set(cache_key, data, 86400)
So Basically we have two functions here :
Go and enjoy the benefit of memcached