(ctx context.Context, key string, value []byte, ttl time.Duration, operation string, f func(ctx context.Context, key string, value []byte, ttl time.Duration) error)
| 599 | } |
| 600 | |
| 601 | func (c *MemcachedClient) storeOperation(ctx context.Context, key string, value []byte, ttl time.Duration, operation string, f func(ctx context.Context, key string, value []byte, ttl time.Duration) error) error { |
| 602 | if !c.itemSizeIsAcceptable(key, value, operation) { |
| 603 | return nil |
| 604 | } |
| 605 | |
| 606 | start := time.Now() |
| 607 | c.metrics.operations.WithLabelValues(operation).Inc() |
| 608 | |
| 609 | err := f(ctx, key, value, ttl) |
| 610 | if err != nil { |
| 611 | c.trackError( |
| 612 | operation, err, |
| 613 | "msg", "failed to store item to cache", |
| 614 | "operation", operation, |
| 615 | "key", key, |
| 616 | "sizeBytes", len(value), |
| 617 | ) |
| 618 | } |
| 619 | |
| 620 | c.metrics.dataSize.WithLabelValues(operation).Observe(float64(len(value))) |
| 621 | c.metrics.duration.WithLabelValues(operation).Observe(time.Since(start).Seconds()) |
| 622 | return err |
| 623 | } |
| 624 | |
| 625 | // wait submits an async task and blocks until it completes. This can be used during |
| 626 | // tests to ensure that async "sets" have completed before attempting to read them. |
no test coverage detected