openresty的缓存机制

1.下载opneresty-1.13.6.1.tar.gz
2.tar zxf opneresty-1.13.6.1.tar.gz
3.cd opneresty-1.13.6.1
4../configure –prefix=/usr/local/lnmp/openresty –with-http_ssl_module –with-http_stub_status_module –user=nginx –group=nginx –with-threads –with-file-aio
5.gmake
6.gmake install
7.cd /usr/local/lnmp/openresty/nginx/conf/
8.vim nginx.conf
http {
upstream memcache {
server locahost:11211;
keepalive 512;
}

location /memc {
internal;
memc_connect_timeout 100ms;
memc_send_timeout 100ms;
memc_read_timeout 100ms;
set $memc_key $query_string;
set $memc_exptime 300;
memc_pass memcache;
}

location ~ .php { ####此处跟上面配置相同      set key u r i args;
srcache_fetch GET /memc k e y ; s r c a c h e s t o r e P U T / m e m c key;
root html;
fastcgi_index index.php
9./usr/local/lnmp/openresty/nginx/sbin/nginx -t
10./usr/local/lnmp/openresty/nginx/sbin/nginx ##打开
11.cd /usr/local/lnmp/openresty/nginx/html/
12.cp /usr/local/lnmp/nginx/html/example.php .
13.cp /usr/local/lnmp/nginx/html/index.php .
14.测试
物理机:
ab -c 10 -n 1000 http://172.25.6.1/example.php
可以看出效率明显高于php下的memcache,是php的3倍左右

猜你喜欢

转载自blog.csdn.net/ningyuxuan123/article/details/81737741