[英]what is the significance of 'retry' and 'every' config parameters in Dancer2::Plugin::Redis
I am using Dancer2::Plugin::Redis plugin to handle the Redis connections.我正在使用 Dancer2::Plugin::Redis 插件来处理 Redis 连接。
In order to provide the required configuration parameters, the documentation gives the following sample .为了提供所需的配置参数,文档中给出了以下示例。
plugins:
Redis:
# if you use TCP/IP:
server: "localhost:6379"
# if you use UNIX/Linux sockets:
sock: "/path/to/sock"
# (optional) Redis password used with auth:
password: "Very secure password 123!"
# (optional) Reconnect up to 60 seconds (reconnect) every 5000 milliseconds (every):
reconnect: 60
every: 5000
# (optional) Redis connection name (NOT the Redis database ID):
name: "my_connection_name"
# (optional) Function called on Redis connect:
on_connect: "MyDancer2App::redis_on_connect"
# (optional) Use serialization for storing values other than simple scalars with Redis:
How does the reconnect
and every
parameters work together? reconnect
和every
参数如何协同工作?
Is it like connection will be alive for 60 seconds and it refreshes every 5 sec?连接是否会存活 60 秒并且每 5 秒刷新一次? If so, it does not make any sense.如果是这样,那就没有任何意义了。
From https://metacpan.org/pod/Redis#reconnect,-every来自https://metacpan.org/pod/Redis#reconnect,-every
The
reconnect
option enables auto-reconnection mode.reconnect
选项启用自动重新连接模式。 If we cannot connect to the Redis server, or if a network write fails, we enter retry mode.如果我们无法连接到Redis服务器,或者网络写入失败,我们将进入重试模式。 We will try a new connection everyevery
microseconds (1 ms by default), up-toreconnect
seconds.我们将every
微秒尝试一个新连接(默认为 1 毫秒),直到reconnect
秒。Be aware that read errors will always thrown an exception, and will not trigger a retry until the new command is sent.请注意,读取错误将始终引发异常,并且在发送新命令之前不会触发重试。
If we cannot re-establish a connection after
reconnect
seconds, an exception will be thrown.如果我们在reconnect
秒后无法重新建立连接,则会抛出异常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.