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

There are some issues with manually managing caching in the database #2770

Closed
ifelsedo opened this issue Jul 16, 2023 · 3 comments
Closed

There are some issues with manually managing caching in the database #2770

ifelsedo opened this issue Jul 16, 2023 · 3 comments
Assignees
Labels
bug It is confirmed a bug, but don't worry, we'll handle it. help wanted planned This issue/proposal is planned into our next steps.

Comments

@ifelsedo
Copy link

ifelsedo commented Jul 16, 2023

1. What version of Go and system type/arch are you using?

$ gf version
GoFrame CLI Tool v2.4.4, https://goframe.org
GoFrame Version: v2.4.4 in current go.mod
CLI Installed At: D:\Golang\bin\gf.exe
Current is a custom installed version, no installation information.

2. What version of GoFrame are you using?

2.4.4

3. Can this issue be re-produced with the latest release?

yes

4. What did you do?

数据库查询缓存里面手动清除缓存的两个方法查看源码发现实现是一样的,都是清除数据库所有缓存。

// ClearCache removes cached sql result of certain table.
func (c *Core) ClearCache(ctx context.Context, table string) (err error)

// ClearCacheAll removes all cached sql result from cache
func (c *Core) ClearCacheAll(ctx context.Context) (err error)

另外一个手动删除指定 key 的缓存的方法不生效,在 Cache 中设置的 Name 无法直接使用

func (Adapter) Remove(ctx context.Context, keys ...interface{}) (lastValue *gvar.Var, err error)

包括 g.DB().GetCache() 下的缓存操作方法无法直接操作链式操作中的 Cache,查看源码才知道有个查询前缀:"SelectCache:"

g.Model("user").Ctx(ctx).Cache(gdb.CacheOption{Duration: time.Hour, Name:"vip-user"}).Where("uid", 1).One() // set cache
g.DB().GetCache().Remove(ctx, "vip-user") // remove fail
g.DB().GetCache().Remove(ctx, "SelectCache:vip-user") // ok

5. What did you expect to see?

希望修复,另外希望在文档中有所提示

6. What did you see instead?

@gqcn gqcn added bug It is confirmed a bug, but don't worry, we'll handle it. help wanted planned This issue/proposal is planned into our next steps. labels Sep 21, 2023
@github-actions
Copy link

Hello @ifelsedo. We like your proposal/feedback and would appreciate a contribution via a Pull Request by you or another community member. We thank you in advance for your contribution and are looking forward to reviewing it!
你好 @ifelsedo。我们喜欢您的提案/反馈,并希望您或其他社区成员通过拉取请求做出贡献。我们提前感谢您的贡献,并期待对其进行审查。

@oldme-git oldme-git self-assigned this Feb 8, 2024
@oldme-git
Copy link
Member

问题汇总到:#3313
show: #3313

@Issues-translate-bot
Copy link

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


Issues summarized to: #3313
show: #3313

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug It is confirmed a bug, but don't worry, we'll handle it. help wanted planned This issue/proposal is planned into our next steps.
Projects
None yet
Development

No branches or pull requests

4 participants