Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gredis cannot override Do method #3191

Closed
merlin888888 opened this issue Dec 8, 2023 · 7 comments
Closed

gredis cannot override Do method #3191

merlin888888 opened this issue Dec 8, 2023 · 7 comments

Comments

@merlin888888
Copy link

gf
使用gredis调用g.redis().Do() 和g.redis().Hset() 方法最后调用的Do方法不一致,请问下为什么不通用上面的Do方法呢?这样可以在业务层实现重写Do方法,增加一些业务处理,如日志记录等需求。
当前继承Adapter,然后使用g.Redis().SetAdapter(),自己实现Do方法,只能覆盖g.redis().Do()一种场景,使用其它封装的命令无法覆盖Do方法。

@Issues-translate-bot Issues-translate-bot changed the title gredis无法重写Do方法 gredis cannot override Do method Dec 8, 2023
@Issues-translate-bot
Copy link

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


gf
When using gredis to call g.redis().Do() and g.redis().Hset(), the Do method finally called is inconsistent. Why not use the above Do method? In this way, the Do method can be rewritten in the business layer and some business processing, such as logging and other requirements can be added.
Currently, you inherit Adapter and then use g.Redis().SetAdapter() to implement the Do method yourself. This can only cover one scenario of g.redis().Do(), and other encapsulated commands cannot cover the Do method.

@hailaz
Copy link
Member

hailaz commented Dec 8, 2023

我觉得你要继承的应该是

type Redis struct {

而不是
type Redis struct {


github.com/gogf/gf/contrib/nosql/redis/v2 才是一个Redis Adapter实现。

@Issues-translate-bot
Copy link

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


I think what you want to inherit should be

type Redis struct {

@hailaz hailaz added the question label Dec 8, 2023
@hailaz
Copy link
Member

hailaz commented Dec 8, 2023

目前没有很好的办法处理这个问题,可能需要改进现有的实现。

@Issues-translate-bot
Copy link

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


There is currently no good way to deal with this problem, and existing implementations may need to be improved.

@hailaz
Copy link
Member

hailaz commented Dec 29, 2023

@merlin888888 已经可以了,如果着急可以试试master分支。具体使用可以看#3194

@Issues-translate-bot
Copy link

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


@merlin888888 It’s already available. If you are in a hurry, you can try the master branch. For specific usage, see #3194

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants