How to increase number of dbs in Azure Cache for Redis

Andrea Manov 0 Reputation points
2024-07-08T07:51:37.6+00:00

I am using Azure Cache for Redis Enterprise (E1) Tier for my application. Due to limit of costs, I would like to use the same instance for two environments: test and staging. How can I create separate db? Is there any limit of the number of dbs because of the tier? I was trying to find in the Microsoft documentation, but I couldn't.

When I try the command INFO keyspace I got this output:

db0:keys=1,expires=0,avg_ttl=0

When I try to SELECT 1 add new KEY I got this error:

Redis Client Error [ErrorReply: ERR DB index is out of range]
Azure Cache for Redis
Azure Cache for Redis
An Azure service that provides access to a secure, dedicated Redis cache, managed by Microsoft.
260 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Sina Salam 12,246 Reputation points
    2024-07-08T21:11:55.86+00:00

    Hello Andrea Manov,

    Welcome to the Microsoft Q&A and thank you for posting your questions here.

    Problem

    I understand based on your explanations that you would like to use same instance of Azure Cache for Redis Enterprise (E1) for two environments and you need how you can create separate db, also you're asking if there any limit of the number of dbs because of the tier and you would like to find Microsoft documentation associated with that.

    Solution

    To use the same instance of Azure Cache for Redis Enterprise (E1) for two environments (test and staging), you can create separate databases within the same Redis instance. I will provide the solution based on the core questions:

    How can I create separate db?

    You can use different database indexes for each environment. For example, use database 0 for the test environment and database 1 for the staging environment.

    1. Use your preferred Redis client to connect to your Azure Cache for Redis instance.
    2. Check the number of available databases: CONFIG GET databases
    3. Use the SELECT command to switch to the desired database: SELECT 1 You can replace 1 with any valid database index.
    4. After switching, you can add keys to the selected database: SET mykey ``"value"
    5. Switch to Database 0 for the Test Environment: SELECT 0
    6. Now, add keys specific to the test environment: SET testKey "testValue"
    7. Switch to Database 1 for the Staging Environment: SELECT 1
    8. Now, add keys specific to the staging environment: SET stagingKey "stagingValue"

    Is there any limit of the number of dbs because of the tier?

    Yes, the number of databases you can use depends on the tier of your Redis instance. For Azure Cache for Redis Enterprise (E1) Tier:

    • The default number of databases is usually 16.
    • This can be configured up to 256 databases depending on the specific Enterprise tier you are using.

    You can verify and set this number using the CONFIG command:

    CONFIG GET databases

    CONFIG SET databases 16``# Example to set it to 16

    I was trying to find in the Microsoft documentation, but I couldn't.

    The followings are Microsoft documentation as requested:

    References

    Kindly use the available additional resources provided by the right side of this page.

    Accept Answer

    I hope this is helpful! Do not hesitate to let me know if you have any other questions.

    ** Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful ** so that others in the community facing similar issues can easily find the solution.

    Best Regards,

    Sina Salam

    0 comments No comments

  2. Oury Ba-MSFT 19,571 Reputation points Microsoft Employee
    2024-07-10T19:58:12.44+00:00

    @Andrea Manov Thank you for reaching out.

    Azure Cache for Redis Enterprise currently supports single database only.

    Multitenancy and Azure Cache for Redis

    see default redis configuration

    Regards,

    Oury


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.