Redis databases on a dev machine with multiple projects

后端 未结 2 1081
抹茶落季
抹茶落季 2021-02-20 07:32

How do you manage multiple projects on your development and/or testing machine, when some of those projects use Redis databases?

There are 2 major problems:

相关标签:
2条回答
  • 2021-02-20 08:27

    If the projects are independent and so do not need to share data, it is much better to use multiple redis instances - each project configuration has a port number rather than a database name/id. Create an appropriately named config file and startup script for each one so that you can get whichever instance you need running with a single click.

    Make sure you update the save settings in each config file as well as setting the ports - Multiple instances using the same dump.rdb file will work, but lead to some rather confusing bugs.

    I also use separate instances for development and testing so that the test instance never writes anything to disk and can be flushed at the start of each test.

    0 讨论(0)
  • 2021-02-20 08:27

    Redis is moving away from multiple databases, so I would recommend you start migrating put of that mechanism sooner rather than later. This means one instance per db. Given the very low overhead of running Redis, this isn't a problem from a resources standpoint.

    That said, you can specify the number of databases, and providing A naming standard would work. For example, configure redis to have say, 60 DBS and you add 10 for the test db. For example db3 uses db13 for testing.

    It sounds like your dev, test, and prod environments are pretty tied together. If so, I'd suggest moving away from that. Using separate instances is the easiest route to that, and provides protection against cross purpose contamination. Between this and the future of redis being single-db per instance, separate instances is the best route.

    0 讨论(0)
提交回复
热议问题