heroku - 使用 Spring Cloud Connector for Heroku 连接多个 RedisLabs 数据库

标签 heroku redis spring-cloud redislabs

我的应用程序需要多个 RedisLabs 数据库,如其主页所述:

multiple dedicated databases in a plan

We enable multiple DBs in a single plan, each running in a dedicated process and in a non-blocking manner.

我靠Spring Cloud Connectors为了连接到 Heroku(或本地的 Foreman),RedisServiceInfoCreator 类似乎允许使用单个 RedisLabs URL,即 REDISCLOUD_URL

这是我配置我的第一个 redis 连接工厂的方式:

@Configuration
@Profile({Profiles.CLOUD, Profiles.DEFAULT})
public class RedisCloudConfiguration extends AbstractCloudConfig  {
    
    @Bean
    public RedisConnectionFactory redisConnectionFactory() {
        PoolConfig poolConfig = ...
        return connectionFactory().redisConnectionFactory("REDISCLOUD", new PooledServiceConnectorConfig(poolConfig));
    }
...

如果我打算使用多个 redis 实验室数据库,我应该如何配置第二个连接工厂

最佳答案

Redis Cloud 将仅为您创建的每个附加组件中的第一个资源设置一个环境变量。

如果您在附加组件中创建多个资源,您应该自己设置一个环境变量,或者直接在您的代码中使用新端点。

关于heroku - 使用 Spring Cloud Connector for Heroku 连接多个 RedisLabs 数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26555734/

相关文章:

redis - 如何使用 Jedis 存储字节数组

java - 当我的 spring Cloud 版本是 Edgware.RELEASE 时,如何 Autowiring 2.x Spring cloud openFeign 接口(interface)? Spring找不到这个bean

spring-cloud - 当实例关闭并转发到其他可用实例时,Spring Cloud Zuul 重试

php - PostgreSQL 使用 PK、NOT NULL、varchar 创建表

node.js - 当我执行 heroku 推送时,为什么 Heroku 告诉我在我的模块中找不到 package.json

caching - 在 Redis 中构建这样的数据是否可行且经济?

node.js - node.js 上的 redis 是同步的还是异步的?

laravel - Heroku 和 Laravel 护照

ruby-on-rails - "rails generate scaffold"上的 "_from.erb"错误(jbuilder 问题?)

java - jhipster应用程序的JWT认证