如何从Redis获取值并将其放入NGiNX中的变量中? [英] How can I get the value from Redis and put it in a variable in NGiNX?
本文介绍了如何从Redis获取值并将其放入NGiNX中的变量中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的配置:
location = /session {
set $redis_key "$cookie_session";
redis_pass 000.00.000.000:6379;
echo $cookie_session;
echo ' - ';
echo $redis_key;
}
回声是为了测试目的.我隐藏了IP.
The echos are there for testing purposes. And I hid the IP.
我正在尝试通过 NGiNX 从 Redis 获取我的会话数据.这就是我安装 HttpRedis 的原因.
I am trying to get my sessions data from Redis via NGiNX. This is why I installed HttpRedis.
我不明白的是如何从 Redis 获取数据然后将其放入变量中.所以我可以随意使用它.
What I don't understand is how I can get the data from Redis then put it in a variable. So I can use it as I please.
推荐答案
使用 NGiNX-Eval-Module:https://github.com/vkholodkov/nginx-eval-module
Use the NGiNX-Eval-Module: https://github.com/vkholodkov/nginx-eval-module
这就是你的做法:
eval $var {
set $redis_key $uri;
redis_pass 000.00.000.000:6379;
}
这篇关于如何从Redis获取值并将其放入NGiNX中的变量中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文