从nginx连接到redis2

我在nginx中configuration一个位置如下:

location /download { secure_link $arg_key,$arg_expires; secure_link_md5 "$secure_link_expires$uri$remote_addr download"; if ($secure_link = "") { return 403; } if ($secure_link = "0") { return 410; } set_unescape_uri $key $arg_key; set_unescape_uri $value $arg_expires; redis2_query setnx $key $value; redis2_pass 127.0.0.1:6379; proxy_pass http://172.16.10.134/$uri; proxy_set_header Host $host; proxy_cache $STATIC; proxy_cache_valid 200 1d; proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504; proxy_cache_min_uses 3; proxy_cache_key $request_uri; } 

在这个configuration中,我想要保护与模块secure_link的链接,并且它完美地工作。 现在我试图通过使用一个链接的一个键更安全地改善它。 我添加一些行:

 set_unescape_uri $key $arg_key; set_unescape_uri $value $arg_expires; redis2_query setnx $key $value; redis2_pass 127.0.0.1:6379; 

命令: redis2_query setnx $key $value将返回1如果密钥不存在,0如果密钥已经。 我想设置一个variables来取这个值然后返回403给用户。 任何机构都有这个想法? 谢谢