fix issue in Cache Penetration for cache feature of package gdb

This commit is contained in:
John Guo
2021-07-21 19:24:16 +08:00
parent 0ddacdd7e2
commit ebe90dcaa8

View File

@ -552,6 +552,10 @@ func (m *Model) doGetAllBySql(sql string, args ...interface{}) (result Result, e
intlog.Error(m.GetCtx(), err)
}
} else {
// In case of Cache Penetration.
if result == nil {
result = Result{}
}
if err := cacheObj.Set(cacheKey, result, m.cacheDuration); err != nil {
intlog.Error(m.GetCtx(), err)
}