tryCacheSet stores the response in cache with row-level indices.
(c context.Context)
| 1218 | |
| 1219 | // tryCacheSet stores the response in cache with row-level indices. |
| 1220 | func (s *gstate) tryCacheSet(c context.Context) { |
| 1221 | if s.gj.responseCache == nil || s.cacheKey == "" || len(s.data) == 0 || s.cacheHit { |
| 1222 | return |
| 1223 | } |
| 1224 | |
| 1225 | cs := s.cs |
| 1226 | if cs == nil || cs.st.qc == nil { |
| 1227 | return |
| 1228 | } |
| 1229 | |
| 1230 | qc := cs.st.qc |
| 1231 | |
| 1232 | // Skip caching for offset-based pagination (pages shift on insert/delete) |
| 1233 | if s.hasOffsetPagination(qc) { |
| 1234 | return |
| 1235 | } |
| 1236 | |
| 1237 | // Skip caching for responses that are too large |
| 1238 | if len(s.data) > maxResponseSize { |
| 1239 | return |
| 1240 | } |
| 1241 | |
| 1242 | // Process response to extract row refs and clean __gj_id fields |
| 1243 | processor := NewResponseProcessor(qc) |
| 1244 | cleaned, refs, err := processor.ProcessForCache(s.data) |
| 1245 | if err != nil { |
| 1246 | return |
| 1247 | } |
| 1248 | |
| 1249 | // Store in cache |
| 1250 | _ = s.gj.responseCache.Set(c, s.cacheKey, cleaned, refs, s.queryStarted) |
| 1251 | } |
| 1252 | |
| 1253 | // invalidateCache invalidates cache entries for rows affected by a mutation. |
| 1254 | func (s *gstate) invalidateCache(c context.Context) { |
nothing calls this directly
no test coverage detected