我正计划向我的 Rails 应用程序添加第二个 Redis 实例。通过阅读文档,https://devcenter.heroku.com/articles/heroku-redis#establish-the-primary-instance ,在 Heroku 上执行此操作的最佳做法似乎是将其中一个实例指定为“主要”实例,使用 REDIS_URL
配置变量指向它,并使用其他名称的另一个配置变量指向第二个实例。
这不太适合我,因为我想使用更多语义名称。
将我的其中一个实例指定为“主要”有多重要?我这样做有什么好处?文档包含诸如“Heroku 建议使用 REDIS_URL
配置变量来存储主实例的位置”之类的句子,但没有进一步详细说明。
最佳答案
REDIS_URL
没有什么神奇之处。支持:
While Heroku recommends to establish a single data store service as a primary and some tools are built around this convention, it is surely possible to have more than one data services with other config var names.
To specify a semantic name for the config var, please add an --as option to the addon:create command like so:
heroku addons:create heroku-redis --as PERSISTENT_REDIS -a my-heroku-app
Moreover, an existing add-on can be attached through a different config var like below. Please refer to the output from the heroku addons command to see what is the add-on name (redis-abc-1234 in the example below) to be used.
heroku addons:attach redis-abc-1234 --as VOLATILE_REDIS -a my-heroku-app
关于ruby-on-rails - Heroku 上多个 Redis 实例的最佳实践?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45201704/