memcache模块安装
执行安装
测试缓存
密码westos,端口11211
nginx的高速缓存
软件下载: https://openresty.org/cn/
软件安装:
#wget https://openresty.org/package/rhel/openresty.repo
#mv openresty.repo /etc/yum.repos.d/
#yum install -y openresty
安装openresty并停止nginx
工作方式改为自动
软件配置:
#cd /usr/local/openresty/nginx/conf
#vim nginx.conf
upstream memcache {
server 127.0.0.1:11211;
keepalive 512; //保持512个不立即关闭的连接用于提升性能
}
location /memc {
internal; //表示只接受内部访问
memc_connect_timeout 100ms;
memc_send_timeout 100ms;
memc_read_timeout 100ms;
set $memc_key
q
u
e
r
y
s
t
r
i
n
g
;
/
/
使
用
内
置
的
query_string; //使用内置的
querystring;//使用内置的query_string来作为key
set KaTeX parse error: Expected 'EOF', got '}' at position 67: …cache; }̲ location ~ \.p… {
set $key
u
r
i
uri
uriargs;
srcache_fetch GET /memc $key;
srcache_store PUT /memc KaTeX parse error: Expected 'EOF', got '#' at position 132: …p; #̲fastcgi_param …fastcgi_script_name;
include fastcgi.conf;
}
测试缓存之后的变化
测试缓存的效果,失败0次,速度加快