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

flexible the cacheconn #3995

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

flexible the cacheconn #3995

wants to merge 5 commits into from

Conversation

0xdoomxy
Copy link

This change is more flexible.We can use the sqlc.cacheConn to obtain the equal effect of sqlx.SqlConn without changing sqlc.cacheConn

This change is more flexible.We can use the sqlc.cacheConn to obtain the equal effect of sqlx.SqlConn without changing sqlc.cacheConn
@@ -88,6 +88,10 @@ func (cc CachedConn) GetCacheCtx(ctx context.Context, key string, v any) error {
return cc.cache.GetCtx(ctx, key, v)
}

func(cc CachedConn)GetRawConnNoCache()sqlx.SqlConn{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When NewConn is used, the conn is passed in from the outside. It is of little significance to provide RawConn here. If you really want to get it, you can save it by the business itself, or explain the value of providing the new method.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

your explanation is reasonable,but this situation need be token care .In the most of environment, i can only declare a cacheConn variable in my servercontext obviously,but according to the real environment,i must to use the conn which skip the cache level in some condition query,because the series query will hit rarely. To make easier operation,i must expose this sqlx.SqlConn to directly use the NonCache query.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To keep the implementation simple, I think it's more straightforward that you keep the reference on your own.

@kevwan kevwan added the area/orm Categorizes issue or PR as related to orm. label Mar 16, 2024
@kevwan kevwan added the do-not-merge/hold Indicates that a PR should not merge because of known issues or need more discussion. label Mar 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/orm Categorizes issue or PR as related to orm. do-not-merge/hold Indicates that a PR should not merge because of known issues or need more discussion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants