go-zero icon indicating copy to clipboard operation
go-zero copied to clipboard

增加选择redis的数据库的功能

Open anxiaowen opened this issue 3 years ago • 19 comments
trafficstars

当前redis模块无法通过配置文件或者redis.New()来选择数据库

anxiaowen avatar Mar 02 '22 04:03 anxiaowen

I think the best practice is not to use DB in redis.

kevwan avatar Mar 02 '22 07:03 kevwan

I think the best practice is not to use DB in redis.

这东西就像核武器 可以不用 但是不能没有 框架理论上应该提供完备的能力

no-serve-people avatar Mar 08 '22 07:03 no-serve-people

如果多应用共用一个db有key冲突的风险(多个应用的key相同了),所以可以通过选择不同的db来规避,当前也可以在框架里面加各自前缀,但是不能保证所有的key都不冲突覆盖。并且对于key的管理,应用之间错开db使用也利于管理。并且增加一个db的选择,对目前的redis模块的使用来说并没有增加额外操作

anxiaowen avatar Mar 08 '22 08:03 anxiaowen

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

Issues-translate-bot avatar Mar 08 '22 08:03 Issues-translate-bot

确实 我觉得也是有必要的.

fyyang avatar Mar 31 '22 09:03 fyyang

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Indeed I think it is necessary.

Issues-translate-bot avatar Mar 31 '22 09:03 Issues-translate-bot

好早之前我就提过这个问题。不能没有。可以不用

smithyj avatar Apr 01 '22 11:04 smithyj

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

Issues-translate-bot avatar Apr 01 '22 11:04 Issues-translate-bot

I have 2 use-cases below which I think supporting db selection in Redis can bring more benefit to developers:

  1. Simplify local + dev env setup
  2. 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.

lanphan avatar Apr 13 '22 16:04 lanphan

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.

wangzeping722 avatar May 12 '22 14:05 wangzeping722

作为框架,可以建议用同一个db,但是不能没有

kunyu avatar May 25 '22 12:05 kunyu

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

Issues-translate-bot avatar May 25 '22 12:05 Issues-translate-bot

I think the best practice is not to use DB in redis.

特别是在测试环境下,有时候需要使用不同的db来隔离数据,不然就需要部署多个redis实例。

2908755265 avatar Jun 07 '22 10:06 2908755265

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

trkjoy avatar Dec 12 '22 02:12 trkjoy

作为框架,可以建议用同一个db,但是不能没有,测试的同学经常为这个头疼,不同应用的用户表,有时候配置一个redis,根本没法区分了

fucktx avatar Sep 22 '23 05:09 fucktx

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.

Issues-translate-bot avatar Sep 22 '23 05:09 Issues-translate-bot

2024了,这个还是不支持吗

gzlboy avatar Nov 24 '24 16:11 gzlboy

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


It’s 2024, is this still not supported?

Issues-translate-bot avatar Nov 24 '24 16:11 Issues-translate-bot

2025, i want it

pig0224 avatar May 18 '25 10:05 pig0224