1

I have a requirement for multiple RedisLabs databases for my application as described in their home page:

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.

I rely on Spring Cloud Connectors in order to connect to Heroku (or Foreman in local) and it seems the RedisServiceInfoCreator class allows for a single RedisLabs URL i.e. REDISCLOUD_URL

Here is how I have configured my first redis connection factory:

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

How I am supposed to configure a second connection factory if I intend to use several redis labs databases?

Community
  • 1
  • 1
balteo
  • 23,602
  • 63
  • 219
  • 412

2 Answers2

1

Redis Cloud will set for you an env var only for the first resource in each add-on that you create.

If you create multiple resources in an add-on, you should either set an env var yourself, or use the new endpoint directly in your code.

Ofir Luzon
  • 10,635
  • 3
  • 41
  • 52
0

In short the answer is yes, RedisConnectionFactory should be using Jedis in order to connect to your redis db. it is using jedis pool that can only work with a single redis endpoint. in this regard there is no different between RedisLabs and a basic redis.

you should create several connection pools to work with several redis dbs/endpoints.

just to extend, if you are using multiple dbs to scale, there is no need with RedisLabs as they support clustering with a single endpoint. so you can simple create a single db with as much memory as needed, RedisLabs will create a cluster for you and will scale your redis automatically.

if you app does require logical seperation, then creation multiple dbs is the right way to go.

Guy Lubovitch
  • 180
  • 1
  • 6
  • Hello Guy Lubovitch, Thanks for you reply. However my question relates to configuring a second connection factory and more specifically what to specify as the second url (environemnt variable name). – balteo Oct 26 '14 at 06:37
  • I do need logical separation so I can't use a single db – balteo Oct 26 '14 at 06:42
  • Please also bear the question relates to Heroku/spring cloud connector. – balteo Oct 26 '14 at 06:57
  • My answer to the question was that you ineeded need to add a new configuration for the second db and each db. you would have done it with jedis pool as well. i will try to provide a full example later on – Guy Lubovitch Oct 27 '14 at 12:13