rediserlangchicagoboss

Chicago_boss and redis config


I am looking to configure a chicago boss application for redis. I am using the eredis gem (https://github.com/wooga/eredis). Is there a way to do this from within my boss.config?


Solution

  • 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.