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

Method SetAsync

cache/memcached_client.go:322–340  ·  view source on GitHub ↗
(key string, value []byte, ttl time.Duration)

Source from the content-addressed store, hash-verified

320}
321
322func (c *MemcachedClient) SetAsync(key string, value []byte, ttl time.Duration) {
323 if !c.itemSizeIsAcceptable(key, value, opSet) {
324 return
325 }
326
327 err := c.queue.submit(func() {
328 // Because this operation is executed in a separate goroutine: We run the operation without
329 // a context (it is expected to keep running no matter what happens) and we don't return the
330 // error (it will be tracked via metrics instead of being returned to the caller).
331 _ = c.storeOperation(context.Background(), key, value, ttl, opSet, func(_ context.Context, key string, value []byte, ttl time.Duration) error {
332 return c.setSingleItem(key, value, ttl)
333 })
334 })
335
336 if err != nil {
337 c.metrics.skipped.WithLabelValues(opSet, reasonAsyncBufferFull).Inc()
338 level.Debug(c.logger).Log("msg", "failed to store item to cache because the async buffer is full", "key", key, "err", err, "buffer_size", c.config.MaxAsyncBufferSize)
339 }
340}
341
342func (c *MemcachedClient) itemSizeIsAcceptable(key string, value []byte, op string) bool {
343 if c.config.MaxItemSize > 0 && len(value) > c.config.MaxItemSize {

Callers 1

SetMultiAsyncMethod · 0.95

Calls 5

itemSizeIsAcceptableMethod · 0.95
storeOperationMethod · 0.95
setSingleItemMethod · 0.95
submitMethod · 0.80
LogMethod · 0.45

Tested by

no test coverage detected