问题是nginx没有获取memcached中存在的memcached密钥,每当我请求链接时都会发生这种情况。nginx无法从memcahed中获取密钥
的分布式缓存的日志:
与关键 “位点/链接” 到分布式缓存zhcon失败Nginx的请求:(但关键数据在分布式缓存)
<31 new auto-negotiating client connection
31: Client using the ascii protocol
<31 get site-/links ### NO DATA SEND! but it in cache
>31 END
<31 connection closed.
Django的与键 “定点/链接” 请求成功memcached的取数据
<31 get :1:mkey
>31 sending key :1:mkeys 0 4
mval
(dp1
.
>31 END
<31 get :1:site-/links
>31 sending key :1:site-/links ###data send!
>31 END
<31 set :1:site-/links 0 300 5518
>31 STORED
<31 set :1:mkey 0 300 4
>31 STORED
<31 connection closed.
我nginx的CFG:
location/{
default_type "text/html; charset=utf-8";
set $memcached_key site-$uri;
memcached_pass 127.0.0.1:11211;
error_page 404 502 = @django;
}
location @django {
include uwsgi_params;
uwsgi_pass unix:///var/tmp/site.sock;
}
Django的middlware:
class NginxMemCacheMiddleWare(object):
def process_response(self, request, response):
cacheIt = True
theUrl = request.get_full_path()
# if it's a GET then store it in the cache:
if request.method != 'GET':
cacheIt = False
# loop on our CACHE_INGORE_REGEXPS and ignore
# certain urls.
for exp in settings.CACHE_IGNORE_REGEXPS:
if re.match(exp,theUrl):
cacheIt = False
if cacheIt:
key = '%s-%s' % (settings.CACHE_KEY_PREFIX,theUrl)
#key = theUrl
print "CACHE!"
print key
print "MKEY:",cache.get("mkey")
print cache.get(key)
cache.set(key,response.content)
cache.set("mkey","mval")
return response
那么,为什么nginx的不能用钥匙这memcached的取数据,总是去Django的uwsgi?