Chicago_boss和redis配置

时间:2015-01-22 23:17:01

标签: redis erlang chicagoboss

我希望为redis配置一个芝加哥boss应用程序。我正在使用eredis gem(https://github.com/wooga/eredis)。有没有办法从我的boss.config中做到这一点?

1 个答案:

答案 0 :(得分:1)

如果你想在CB中使用eredis缓存,我有个坏消息。根据{{​​3}}:

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

但是,如果您想在应用程序中使用eredis来代替其他内容,那么根据documentation,您需要在启动时提供详细信息:

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)获取主机名并在启动时使用它。