(ctx context.Context, replace bool)
| 327 | } |
| 328 | |
| 329 | func (entry *CacheEntry) flushToDB(ctx context.Context, replace bool) error { |
| 330 | if entry.File == nil { |
| 331 | return nil |
| 332 | } |
| 333 | err := dbWriteCacheEntry(ctx, entry.File, entry.DataEntries, replace) |
| 334 | if ctx.Err() != nil { |
| 335 | // transient error |
| 336 | return ctx.Err() |
| 337 | } |
| 338 | if err != nil { |
| 339 | flushErrorCount.Add(1) |
| 340 | entry.FlushErrors++ |
| 341 | if entry.FlushErrors > 3 { |
| 342 | entry.clear() |
| 343 | return fmt.Errorf("too many flush errors (clearing entry): %w", err) |
| 344 | } |
| 345 | return err |
| 346 | } |
| 347 | // clear cache entry (data is now in db) |
| 348 | entry.clear() |
| 349 | return nil |
| 350 | } |
no test coverage detected