点赞
评论
收藏
分享
举报
redis_nginx_adapter
发表于2020-09-23 21:10

浏览 1k

文章标签

授权协议:
MIT license
原作者联系方式:
Wandenberg Peixoto <wandenberg@gmail.com>
功能说明:
Redis Nginx 适配器

redis_nginx_adapter

An adapter to use the events structure from Nginx on communication with redis, using redis asynchronous context. It requires hiredis >= 0.11.0, and Nginx headers.

Installation

  • get Nginx source and configure it with ./configure
  • get hiredis source, configure and install it
  • configure redis_nginx_adapter pointing to nginx source dir and hiredis like ./configure --with-nginx-dir=../nginx-1.7.1 --with-hiredis-dir=/opt --with-openssl-dir=/usr/local/opt/openssl make make install

Basic usage

Without authentication

redis_nginx_init();
redisAsyncContext *redis_server = NULL;
if (redis_nginx_open_context((const char *) "localhost", 6379, 0, NULL, &redis_server) != NULL) {
    redisAsyncCommand(redis_server, NULL, NULL, "SET %b %d-%d", r->uri.data, r->uri.len, r->headers_out.status, r->headers_out.content_length_n);
}
redis_nginx_close_context(&redis_server);

With authentication

redis_nginx_init();
redisAsyncContext *redis_server = NULL;
if (redis_nginx_open_context((const char *) "localhost", 6379, 0, (const char*) "password", &redis_server) != NULL) {
    redisAsyncCommand(redis_server, NULL, NULL, "SET %b %d-%d", r->uri.data, r->uri.len, r->headers_out.status, r->headers_out.content_length_n);
}
redis_nginx_close_context(&redis_server);

Example

At the example/module folder there is a very basic Nginx module that uses the library. And a Dockerfile that demonstrate how to build and run it.


已修改于2023-03-09 02:20
本作品系原创
创作不易,留下一份鼓励
皮皮鲁

暂无个人介绍

关注



写下您的评论
发表评论
全部评论(0)

按点赞数排序

按时间排序

关于作者
皮皮鲁
这家伙很懒还未留下介绍~
85
文章
2
问答
41
粉丝
相关文章