UpsertCacheKey records the in-memory OpCache key + IsBackendOp flag on the gallery_operations row, creating the row if it does not exist yet. Why upsert: OpCache.Set is called by the HTTP admission handler before the galleryop service goroutine processes the operation and calls Create. If OpCache w
(id, cacheKey string, isBackend bool)
| 150 | // in the window between the two, so peer replicas hydrating in that window |
| 151 | // would still rebuild an empty OpCache. Upsert closes that window. |
| 152 | func (s *GalleryStore) UpsertCacheKey(id, cacheKey string, isBackend bool) error { |
| 153 | now := time.Now() |
| 154 | rec := GalleryOperationRecord{ |
| 155 | ID: id, |
| 156 | CacheKey: cacheKey, |
| 157 | IsBackendOp: isBackend, |
| 158 | Status: "pending", |
| 159 | CreatedAt: now, |
| 160 | UpdatedAt: now, |
| 161 | } |
| 162 | return s.db.Clauses(clause.OnConflict{ |
| 163 | Columns: []clause.Column{{Name: "id"}}, |
| 164 | DoUpdates: clause.Assignments(map[string]any{ |
| 165 | "cache_key": cacheKey, |
| 166 | "is_backend_op": isBackend, |
| 167 | "updated_at": now, |
| 168 | }), |
| 169 | }).Create(&rec).Error |
| 170 | } |
| 171 | |
| 172 | // FindDuplicate checks if another instance is already downloading the same element. |
| 173 | // Only considers records updated within the last 30 minutes as active — older |
no test coverage detected