go-zero
go-zero copied to clipboard
增加选择redis的数据库的功能
当前redis模块无法通过配置文件或者redis.New()来选择数据库
I think the best practice is not to use DB in redis.
I think the best practice is not to use DB in redis.
这东西就像核武器 可以不用 但是不能没有 框架理论上应该提供完备的能力
如果多应用共用一个db有key冲突的风险(多个应用的key相同了),所以可以通过选择不同的db来规避,当前也可以在框架里面加各自前缀,但是不能保证所有的key都不冲突覆盖。并且对于key的管理,应用之间错开db使用也利于管理。并且增加一个db的选择,对目前的redis模块的使用来说并没有增加额外操作
Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑🤝🧑👫🧑🏿🤝🧑🏻👩🏾🤝👨🏿👬🏿
If multiple applications share a db, there is a risk of key conflict (the keys of multiple applications are the same), so you can avoid it by selecting different dbs. Currently, you can also add their own prefixes to the framework, but there is no guarantee that all keys will not conflict. cover. And for key management, staggering the use of db between applications is also conducive to management. And adding a db option does not add additional operations to the current use of the redis module
确实 我觉得也是有必要的.
Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑🤝🧑👫🧑🏿🤝🧑🏻👩🏾🤝👨🏿👬🏿
Indeed I think it is necessary.
好早之前我就提过这个问题。不能没有。可以不用
Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑🤝🧑👫🧑🏿🤝🧑🏻👩🏾🤝👨🏿👬🏿
I raised this question a long time ago. Can't do without. Its not mandatory
I have 2 use-cases below which I think supporting db selection in Redis can bring more benefit to developers:
- Simplify local + dev env setup
- In case 1 Redis db is used for different purposes, for ex: cache + queue, it'll be dangerous to do action "clear cache" which will clear all queue data also.
When we use redis in dev or test environment, we need reuse the redis server with different db. But in prod environment, just use db0.
作为框架,可以建议用同一个db,但是不能没有
Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑🤝🧑👫🧑🏿🤝🧑🏻👩🏾🤝👨🏿👬🏿
As a framework, it can be recommended to use the same db, but not without
I think the best practice is not to use DB in redis.
特别是在测试环境下,有时候需要使用不同的db来隔离数据,不然就需要部署多个redis实例。
I think the best practice is not to use DB in redis.
In some refactored systems, the data is originally written in a non-zero database. At this time, it is necessary to choose to set the database
作为框架,可以建议用同一个db,但是不能没有,测试的同学经常为这个头疼,不同应用的用户表,有时候配置一个redis,根本没法区分了
Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑🤝🧑👫🧑🏿🤝🧑🏻👩🏾🤝👨🏿👬🏿
As a framework, it is recommended to use the same db, but it cannot be used without it. Test students often have a headache for this. User tables of different applications can sometimes be configured with a redis and cannot be distinguished at all.
2024了,这个还是不支持吗
Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑🤝🧑👫🧑🏿🤝🧑🏻👩🏾🤝👨🏿👬🏿
It’s 2024, is this still not supported?
2025, i want it