Skip to content

Commit ebe90dc

Browse files
committed
fix issue in Cache Penetration for cache feature of package gdb
1 parent 0ddacdd commit ebe90dc

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

database/gdb/gdb_model_select.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,10 @@ func (m *Model) doGetAllBySql(sql string, args ...interface{}) (result Result, e
552552
intlog.Error(m.GetCtx(), err)
553553
}
554554
} else {
555+
// In case of Cache Penetration.
556+
if result == nil {
557+
result = Result{}
558+
}
555559
if err := cacheObj.Set(cacheKey, result, m.cacheDuration); err != nil {
556560
intlog.Error(m.GetCtx(), err)
557561
}

0 commit comments

Comments
 (0)