1

I want to connect to a specific database in our new Azure Redis cache but can't seem to figure out how to do it.

I've tried adding the database id to connection string in various forms as well as looking for GetDatabase(dbid) on the IDistributedcache object (which doesn't seem to exist).

FYI, I want to use the same cache for our testing and production without having to pay for an additional redis cache so I'm open to alternative approaches.

3
  • I've seen the same cache used for non-prod and production before and it can potentially be a huge pain point. Be sure to consider the risk of accidentally having data cross between the two while you're determining how your keys are going to work. Commented Sep 28, 2017 at 1:17
  • And this is why I really wanted to separate them using different databases in the redis cache. Commented Sep 28, 2017 at 1:27
  • So I think the best way to do this is to use a ConnectionMultiplexer as a singleton service (which means you can use a config object and also means a lot less time creating connections to Redis too). I'll experiment and add my answer later for anyone else that runs in to this as it took me a while to figure out this was the best approach. Commented Sep 29, 2017 at 2:47

1 Answer 1

1

You could also use the ConnectionMultiplexer object directly and access the Database via the GetDatabase method.

Sign up to request clarification or add additional context in comments.

1 Comment

This is what I did in the end.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.