Django,nginx和uWSGIcaching结果,直到uWSGI / MySQL重新启动

我已经在Django中编写了一个服务器应用程序,并向Tastypie的移动应用程序提供API,并使用本地MySQL服务器为数据库提供服务。

似乎查询被caching,直到进程被终止或结束。 如果我在后端创build一个新用户,它将首先出现在列表中,如果我重新启动uWSGI或MySQL,或者如果我从另一个浏览器login到后端。

Mysql进程列表

41 example localhost:58747 example 13 Sleep 42 example localhost:58748 example 16 Sleep 

另外,如果我杀死了Sleep'ed进程,它也会触发刷新数据。

uWSGIconfiguration

 [uwsgi] vhost = true plugins = python socket = /tmp/example.com.sock master = true enable-threads = true processes = 2 wsgi-file = /var/sites/example-server/example/example/wsgi.py virtualenv = /var/sites/example-server/PYTHON_ENV chdir = /var/sites/example-server/example touch-reload = /var/sites/example-server/example/reload 

nginxconfiguration

 server { client_max_body_size 20M; listen 80; server_name example.com; access_log /var/log/nginx/example.com_access.log; error_log /var/log/nginx/example.com_error.log; location / { uwsgi_pass unix:///tmp/example.com.sock; include uwsgi_params; } location /media/ { alias /var/sites/example-server/example/example/media/; } location /static/ { alias /var/sites/example-server/example/example/static/; } } 

my.cnf中

 [client] port = 3306 socket = /var/run/mysqld/mysqld.sock [mysqld_safe] socket = /var/run/mysqld/mysqld.sock nice = 0 [mysqld] user = mysql pid-file = /var/run/mysqld/mysqld.pid socket = /var/run/mysqld/mysqld.sock port = 3306 basedir = /usr datadir = /var/lib/mysql tmpdir = /tmp lc-messages-dir = /usr/share/mysql skip-external-locking bind-address = 127.0.0.1 key_buffer = 16M max_allowed_packet = 16M thread_stack = 192K thread_cache_size = 8 myisam-recover = BACKUP query_cache_limit = 1M query_cache_size = 16M log_error = /var/log/mysql/error.log expire_logs_days = 10 max_binlog_size = 100M mysqldump] quick quote-names max_allowed_packet = 16M [mysql] [isamchk] key_buffer = 16M transaction-isolation = READ-COMMITTED !includedir /etc/mysql/conf.d/ 

我能做些什么来解决这个问题呢?

干杯莫滕

我有相同的行为,发现这个帖子https://plus.google.com/u/0/101898908470597791359/posts/AuMJdgEo93k

在Django的settings.py(只有OPTIONS键)上添加这一行:

 DATABASES = { 'default': { 'OPTIONS': { "init_command": "SET storage_engine=INNODB, SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED", } } } 

似乎已经解决了这个问题。