zoukankan      html  css  js  c++  java
  • 9.nginx使用redis用缓存

    需要使用到的第三方模块,因为在有道笔记上面,所以为办法直接给你们,需要的话给我私信或者邮件(913956964@qq.com)

    1.编译安装,添加上述扩展插件
    ./configure --prefix=/usr/local/nginx --without-http_memcached_module --user=www --group=www --with-http_stub_status_module --with-openssl=/usr/ --with-pcre=/usr/local/src/pcre-8.31 --with-http_stub_status_module --add-module=/usr/local/src/ngx_devel_kit-master --add-module=/usr/local/src/set-misc-nginx-module-0.29 --add-module=/usr/local/src/srcache-nginx-module-0.30 --add-module=/usr/local/src/redis2-nginx-module-0.12 --add-module=/usr/local/src/echo-nginx-module-0.58
     
    2.修改nginx.conf配置
    location ~ .*.php {
      root html;
                    srcache_store_private on;
                    srcache_methods GET;
                    srcache_response_cache_control off;
       
                    if ($uri ~ .*.php$){
                            set $key $request_uri;
                            set_escape_uri $escaped_key $key;
                            srcache_fetch GET /redis $key;
                            srcache_default_expire 172800;
                            srcache_store PUT /redis2 key=$escaped_key&exptime=$srcache_expire;
     }
                    include fastcgi_params;
                    fastcgi_pass  127.0.0.1:9000;
                    fastcgi_index index.php;
                    fastcgi_connect_timeout 60;
                    fastcgi_send_timeout 180;
                    fastcgi_read_timeout 180;
                    fastcgi_buffer_size 128k;
                    fastcgi_buffers 4 256k;
                    fastcgi_busy_buffers_size 256k;
                    fastcgi_temp_file_write_size 256k;
                    fastcgi_intercept_errors on;
                    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                    fastcgi_split_path_info ^(.+.php)(.*)$;
                    fastcgi_param PATH_INFO $fastcgi_path_info;
             }
     
            location = /redis {
                    internal;
                    set_md5 $redis_key $args;
                    redis2_pass 127.0.0.1:6379;
            }
     
            location = /redis2 {
                    internal;
     
                    set_unescape_uri $exptime $arg_exptime;
                    set_unescape_uri $key $arg_key;
                    set_md5 $key;
     
                    redis2_query set $key $echo_request_body;
                    redis2_query expire $key $exptime;
                    redis2_pass 127.0.0.1:6379;
            }
     
    3.redis检查是否产生key值
    redis-cli
    keys *
    info
    dbsize
    每天学习一点点,重在积累!
  • 相关阅读:
    白盒测试相关技术图架构
    LoadRunner面试题
    调用标准API抓取错误信息
    请求的报的一般错误:One or more post-processing actions failed. Consult the OPP service log for details.
    xml publisher笔记
    CREATE_RECORD或者NEXT_RECORD导致 FRM-40102 错误:记录必须首先被输入或者删除
    国外博士论文下载
    数据挖掘网络资源集合
    十大数据挖掘算法
    (转)数据挖掘——我们能从股市数据得出什么,以及一些算法
  • 原文地址:https://www.cnblogs.com/GXLo/p/5169160.html
Copyright © 2011-2022 走看看