(key string, value []byte, ttl time.Duration)
| 320 | } |
| 321 | |
| 322 | func (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 | |
| 342 | func (c *MemcachedClient) itemSizeIsAcceptable(key string, value []byte, op string) bool { |
| 343 | if c.config.MaxItemSize > 0 && len(value) > c.config.MaxItemSize { |
no test coverage detected