Chicago_boss 和 redis 配置

Chicago_boss and redis config

我正在寻找为 Redis 配置芝加哥老板应用程序。我正在使用 eredis gem (https://github.com/wooga/eredis)。有没有办法在我的 boss.config 中执行此操作?

如果您想在 CB 中使用 eredis 进行缓存,我有一个坏消息要告诉您。根据documentation:

At present only Memcached cache servers are supported,
but additional adapters will be added in the future.

但是,如果您想在应用程序中将 eredis 用于其他用途,则根据 eredis docs 您需要在启动时提供详细信息:

To start the client, use any of the eredis:start_link/0,1,2,3,4,5 functions. They all include sensible defaults. start_link/5 takes the following arguments:

Host, dns name or ip adress as string
Port, integer, default is 6379
Database, integer or 0 for default database
Password, string or empty string([]) for no password
Reconnect sleep, integer of milliseconds to sleep between reconnect attempts

如果您不想在启动应用程序的代码中硬编码这些值,您可以在 boss.config:

中提供它们
{ your_app_name, [
    {eredis_host, "some.host.name"},
    {eredis_port, 1234},
    ...
]}

然后,在您的代码中,您可以使用 EredisHost = application:get_env(your_app_name, eredis_host) 获取主机名并在启动期间使用它。