gdb returns result when cache set failed

This commit is contained in:
qinyuguang 2022-03-10 14:50:06 +08:00
parent ba7cbfe3d9
commit a4ab9c284f

View File

@ -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)
}
}
}