High Performance URL-Shortening with Redis-backed nginx

High Performance URL-Shortening with Redis-backed nginx.

location /redis {
        internal;
        redis2_query get $request_uri;
        set_unescape_uri $query $arg_query;
        redis2_raw_query $query;
        redis2_pass 127.0.0.1:6379;
}
location / {
        content_by_lua ‘
                local res = ngx.location.capture(“/redis”,
                        { args = { query = “$request_uri\\r\\n” } }
                )
                local href = string.gsub(res.body, “\$[0-9]+\\r\\n”, “”);
                ngx.redirect(href);
        ‘;
}
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s