【问题标题】:define db value while creating connection with redis into nginx.conf file while using Openresty在使用 Openresty 时在 nginx.conf 文件中创建与 redis 的连接时定义 db 值
【发布时间】:2013-12-06 07:17:30
【问题描述】:

我将 Redis 与在 nginx 上运行的 Django 项目一起使用,我正在通过代码创建连接

red = redis.Redis("localhost", port=6397, db=5, socket_timeout=2)

现在通过使用 Openresty,我使用 lua 从 Redis 获取缓存数据到 nginx.conf 文件中,我能够创建连接

本地 redis = 需要“resty.redis” 本地红色 = redis:new() red:set_timeout(1000) -- 1 秒 本地正常,错误 = 红色:连接(“10.0.0.161”,6379)

在 nginx.conf 文件中,我无法理解如何定义 db 值。 我试过local ok, err = red:connect("10.0.0.161", 6379, {db=5) 但它不起作用。
请帮帮我。

【问题讨论】:

    标签: nginx lua


    【解决方案1】:

    连接后使用 select:

    red:select(5)
    

    【讨论】:

      猜你喜欢
      • 2013-12-23
      • 2016-02-18
      • 2021-11-08
      • 1970-01-01
      • 2020-05-13
      • 2022-10-21
      • 2010-11-28
      • 2016-05-30
      相关资源
      最近更新 更多