乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      srcache_nginx+redis構(gòu)建緩存系統(tǒng)

       亭下走馬 2016-01-05

      在《memc_nginx+srcache_nginx+memcached構(gòu)建透明的動態(tài)頁面緩存》一文中,我們使用到memcached來作為緩存載體。想必大家都知道m(xù)emcached有存儲大小的限制,不得超過1M。 本文將使用redis來作為緩存載體。nginx的srcache_nginx模塊指令參數(shù)解釋參見《memc_nginx+srcache_nginx+memcached構(gòu)建透明的動態(tài)頁面緩存》。

      1. nginx模塊

      1
      2
      3
      4
      5
      --add-module=../modules/ngx_devel_kit-0.2.18
      --add-module=../modules/set-misc-nginx-module-0.22rc8
      --add-module=../modules/srcache-nginx-module-0.22
      --add-module=../modules/redis-nginx-module-0.3.6
      --add-module=../modules/redis2-nginx-module-0.10

      nginx模塊安裝參見中相關(guān)文檔。

      2. redis安裝配置

      安裝步驟參見:http://www./html/1646.html
      配置參數(shù)解釋參見:http://www./html/1226.html
      配置實例:
      # vim redis.conf

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      24
      25
      26
      27
      28
      29
      30
      31
      32
      33
      34
      35
      36
      37
      38
      39
      40
      daemonize yes
      pidfile /var/run/redis-6379.pid
      port 6379
      bind 127.0.0.1
      timeout 0
      tcp-keepalive 0
      loglevel notice
      logfile stdout
      databases 16
      stop-writes-on-bgsave-error yes
      rdbcompression yes
      rdbchecksum yes
      dbfilename dump.rdb
      slave-serve-stale-data yes
      slave-read-only yes
      repl-disable-tcp-nodelay no
      slave-priority 100
      maxmemory 8096mb
      maxmemory-policy volatile-ttl
      appendonly no
      appendfsync everysec
      no-appendfsync-on-rewrite no
      auto-aof-rewrite-percentage 100
      auto-aof-rewrite-min-size 64mb
      lua-time-limit 5000
      slowlog-log-slower-than 10000
      slowlog-max-len 128
      hash-max-ziplist-entries 512
      hash-max-ziplist-value 64
      list-max-ziplist-entries 512
      list-max-ziplist-value 64
      set-max-intset-entries 512
      zset-max-ziplist-entries 128
      zset-max-ziplist-value 64
      activerehashing yes
      client-output-buffer-limit normal 0 0 0
      client-output-buffer-limit slave 256mb 64mb 60
      client-output-buffer-limit pubsub 32mb 8mb 60
      hz 10
      aof-rewrite-incremental-fsync yes

      由于只把redis當(dāng)做緩存使用,因此沒有啟用持久化。

      3. nginx配置

      # vim nginx.conf

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      http
      {
              include       mime.types;
              default_type  application/octet-stream;
              log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                                              '"$status" $body_bytes_sent "$http_referer" '
                                              '"$http_user_agent" "$http_x_forwarded_for" '
                                              '"$gzip_ratio" $request_time $bytes_sent $request_length';
              log_format srcache_log '$remote_addr - $remote_user [$time_local] "$request" '
                                      '"$status" $body_bytes_sent $request_time $bytes_sent $request_length '
                                      '[$upstream_response_time] [$srcache_fetch_status] [$srcache_store_status] [$srcache_expire]';
              set_real_ip_from 10.0.0.0/8;
              real_ip_header X-Forwarded-For;
              include          vhosts/test..conf;
      }

      # vim vhosts/test..conf

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      24
      25
      26
      27
      28
      29
      30
      31
      32
      33
      34
      35
      36
      37
      38
      39
      40
      41
      42
      43
      44
      45
      46
      47
      48
      49
      50
      51
      52
      53
      54
      55
      56
      57
      58
      59
      60
      61
      62
      63
      64
      65
      66
      67
      68
      69
      70
      71
      72
      73
      upstream redis {
              server 127.0.0.1:6379;
              keepalive 512;
      }
      server
             {
              listen       80;
              server_name  test.;
              index index.html index.htm index.php;
              root  /data/test./webroot;
              location ~ .*\.php {
                      srcache_store_private on;
                      srcache_methods GET;
                      srcache_response_cache_control off;
                      if ($uri ~ //pp.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;
                              #add_header X-Cached-From $srcache_fetch_status;
                              #set_md5 $md5key $key;
                              #add_header X-md5-key $md5key;
                              #add_header X-Cached-Store $srcache_store_status;
                              #add_header X-Key $key;
                              #add_header X-Query_String $query_string;
                              #add_header X-expire $srcache_expire;
      access_log /data/httplogs/test.-photo-access.log srcache_log;
                      }
                      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;
                      redis_pass redis;
              }
              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 redis;
              }
              error_log  /data/httplogs/test.-error.log;
              access_log  /data/httplogs/test.-aceess.log main;
      }

      4. 測試

      沒有做緩存狀態(tài):
      memc-nginx
      有做緩存狀態(tài):
      memc-nginx

      5. 響應(yīng)頭狀態(tài)

      第一次請求:
      memc-nginx
      再次請求:
      memc-nginx

      6. 查看redis是否緩存以及過期時間

      memc-nginx

      如需轉(zhuǎn)載請注明出處: http://www./html/3156.html

        本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
        轉(zhuǎn)藏 分享 獻花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多