0

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

4

1 回答 1

1

If you want to use eredis for caching in CB, I have bad news for you. According to documentation:

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

However, if you want to use eredis for something else in your application, then according to eredis docs you need to provide the details at startup:

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

If you don't want to hard-code those values in the code, that starts the application, you can provide them in boss.config:

{ your_app_name, [
    {eredis_host, "some.host.name"},
    {eredis_port, 1234},
    ...
]}

Then, in your code, you can use EredisHost = application:get_env(your_app_name, eredis_host) to obtain the host name and use it during start.

于 2015-01-23T15:47:07.220 回答