mirror of
https://gitee.com/johng/gf.git
synced 2024-11-29 18:57:44 +08:00
gdb returns result when cache set failed
This commit is contained in:
parent
ba7cbfe3d9
commit
a4ab9c284f
@ -538,16 +538,16 @@ func (m *Model) doGetAllBySql(sql string, args ...interface{}) (result Result, e
|
||||
// Cache the result.
|
||||
if cacheKey != "" && err == nil {
|
||||
if m.cacheOption.Duration < 0 {
|
||||
if _, err = cacheObj.Remove(ctx, cacheKey); err != nil {
|
||||
intlog.Errorf(m.GetCtx(), `%+v`, err)
|
||||
if _, errCache := cacheObj.Remove(ctx, cacheKey); errCache != nil {
|
||||
intlog.Errorf(m.GetCtx(), `%+v`, errCache)
|
||||
}
|
||||
} else {
|
||||
// In case of Cache Penetration.
|
||||
if result.IsEmpty() && m.cacheOption.Force {
|
||||
result = Result{}
|
||||
}
|
||||
if err = cacheObj.Set(ctx, cacheKey, result, m.cacheOption.Duration); err != nil {
|
||||
intlog.Errorf(m.GetCtx(), `%+v`, err)
|
||||
if errCache := cacheObj.Set(ctx, cacheKey, result, m.cacheOption.Duration); errCache != nil {
|
||||
intlog.Errorf(m.GetCtx(), `%+v`, errCache)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user