使用Django配置Memcached [英] Configuring memcached with django

查看:54
本文介绍了使用Django配置Memcached的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Ubuntu 16.04 VPS,其中有一个使用uwsgi和nginx运行的django 1.8应用程序.我想为django安装memcached,因此我一直在查看 https://docs.djangoproject.com/en/1.8/topics/cache/.我想将pylibmc用作memcached客户端.

I'm working with an ubuntu 16.04 VPS, where I have a django 1.8 app running using uwsgi and nginx. I want to install memcached for django , so I've been looking at https://docs.djangoproject.com/en/1.8/topics/cache/. I want to use pylibmc as my memcached client.

基于此,我添加了:

CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
        'LOCATION': '/tmp/memcached.sock',
    }
}

到我的settings.py.但是当我跑步

to my settings.py. But when I run

(myenv) deploy@server:~$ sudo systemctl status memcached
● memcached.service - memcached daemon
Loaded: loaded (/lib/systemd/system/memcached.service; enabled; vendor preset
Active: active (running) since Fri 2017-02-17 11:21:07 EST; 5s ago
Main PID: 5562 (memcached)
CGroup: /system.slice/memcached.service
        └─5562 /usr/bin/memcached -m 64 -p 11211 -u memcache -l 127.0.0.1

基于输出,看来memcached正在使用ip地址和端口(如果我理解正确).如何配置memcached以使用django套接字后端?

Based on the output it appears that memcached is using an ip address and port (if I understand correctly) .How can I configure memcached to use the django socket backend?

推荐答案

修改/etc/memcached.conf

注释 -p -l <​​/code>-禁用TCP套接字

Comment -p and -l - This disables TCP sockets

添加 -s/tmp/memcached.sock 并重新启动守护程序

Add -s /tmp/memcached.sock and restart the daemon

https://linux.die.net/man/1/memcached

这篇关于使用Django配置Memcached的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆