sudo apt-get install memcached
由于memcached依赖于libevent;因此,还需要安装libevent,命令如下:
sudo apt-get install libevent-dev
pip3 install python3-memcached
settings.py
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': [
'127.0.0.1:11211',
]
}
}
sudo service memcached start
@cache_page(60 * 15)
def index(request):
pass