MCPcopy
hub / github.com/grafana/dskit / storeOperation

Method storeOperation

cache/memcached_client.go:601–623  ·  view source on GitHub ↗
(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)

Source from the content-addressed store, hash-verified

599}
600
601func (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.

Callers 4

SetAsyncMethod · 0.95
SetMethod · 0.95
AddMethod · 0.95
CompareAndSwapMethod · 0.95

Calls 2

itemSizeIsAcceptableMethod · 0.95
trackErrorMethod · 0.95

Tested by

no test coverage detected