GithubHelp home page GithubHelp logo

thevuuranusls / ngx_http_redis Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hoopchina/ngx_http_redis

0.0 0.0 0.0 107 KB

You can use this module to perform simple caching through Redis.

License: Other

C 68.02% Perl 31.98%

ngx_http_redis's Introduction

nginx HTTP redis module
--

Description:
--

The nginx HTTP redis module for caching with redis,
http://code.google.com/p/redis/.

The redis protocol
(http://code.google.com/p/redis/wiki/ProtocolSpecification)
not yet fully implemented, but GET and SELECT commands only.



Installation:
--

You'll need to re-compile Nginx from source to include this module.
Modify your compile of Nginx by adding the following directive
(modified to suit your path of course):

./configure --add-module=/absolute/path/to/ngx_http_redis
make
make install



Usage:
--

Example 1.


http
{
 ...
        server {
                location / {
                        set $redis_key  "$uri?$args";
                        redis_pass      127.0.0.1:6379;
                        error_page      404 502 504 = @fallback;
                }

                location @fallback {
                        proxy_pass      backed;
                }
        }
}


Example 2.

Capture User-Agent from an HTTP header, query to redis database
for lookup appropriate backend.

Eval module (http://www.grid.net.ru/nginx/eval.en.html) required.

http
{
 ...
    upstream redis {
        server  127.0.0.1:6379;
    }

    server {
     ...
        location / {

	    eval_escalate on;

	    eval $answer {
		set $redis_key	"$http_user_agent";
		redis_pass	redis;
	    }

            proxy_pass $answer;
        }
        ...
     }
}


Example 3.

Compile nginx with ngx_http_redis and ngx_http_gunzip_filter modules
(http://mdounin.ru/hg/ngx_http_gunzip_filter_module/).
Gzip content and put it into redis database.

% cat index.html
<html><body>Hello from redis!</body></html>
% gzip index.html
% cat index.html.gz | redis-cli -x set /index.html
OK
% cat index.html.gz | redis-cli -x set /
OK
%

Using following configuration nginx get data from redis database and
gunzip it.

http
{
 ...
    upstream redis {
        server  127.0.0.1:6379;
    }

    server {
     ...
        location / {
                gunzip on;
                redis_gzip_flag 1;
                set $redis_key "$uri";
                redis_pass redis;
    }
}



Thanks to:
--

Maxim Dounin
Vsevolod Stakhov
Ezra Zygmuntowicz



Special thanks to:
--
Evan Miller for his "Guide To Nginx Module Development" and "Advanced Topics
In Nginx Module Development"
Valery Kholodkov for his "Nginx modules development"

ngx_http_redis's People

Contributors

soplwang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.