Cache cannot be disabled from v1.22. So it still maybe `nil` in v1.21, we have to check whether cache is `nil`.
Fix #30421 Backport #30426 Co-authored-by: Jason Song <i@wolfogre.com>
backport #29444