MCPcopy
hub / github.com/gogf/gf / checkAndRemoveSelectCache

Method checkAndRemoveSelectCache

database/gdb/gdb_model_cache.go:67–74  ·  view source on GitHub ↗

checkAndRemoveSelectCache checks and removes the cache in insert/update/delete statement if cache feature is enabled.

(ctx context.Context)

Source from the content-addressed store, hash-verified

65// checkAndRemoveSelectCache checks and removes the cache in insert/update/delete statement if
66// cache feature is enabled.
67func (m *Model) checkAndRemoveSelectCache(ctx context.Context) {
68 if m.cacheEnabled && m.cacheOption.Duration < 0 && len(m.cacheOption.Name) > 0 {
69 var cacheKey = m.makeSelectCacheKey("")
70 if _, err := m.db.GetCache().Remove(ctx, cacheKey); err != nil {
71 intlog.Errorf(ctx, `%+v`, err)
72 }
73 }
74}
75
76func (m *Model) getSelectResultFromCache(ctx context.Context, sql string, args ...any) (result Result, err error) {
77 if !m.cacheEnabled || m.tx != nil {

Callers 3

DeleteMethod · 0.95
doInsertWithOptionMethod · 0.95
UpdateMethod · 0.95

Calls 4

makeSelectCacheKeyMethod · 0.95
ErrorfFunction · 0.92
RemoveMethod · 0.65
GetCacheMethod · 0.65

Tested by

no test coverage detected