| 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 { |
| 344 | c.metrics.skipped.WithLabelValues(op, reasonMaxItemSize).Inc() |
| 345 | c.metrics.skippedDataSize.WithLabelValues(op).Observe(float64(len(value))) |
| 346 | level.Debug(c.logger).Log("msg", "failed to store item to cache because it is too large", "key", key, "size", len(value), "max_item_size", c.config.MaxItemSize, "op", op) |
| 347 | return false |
| 348 | } |
| 349 | |
| 350 | return true |
| 351 | } |
| 352 | |
| 353 | func (c *MemcachedClient) Set(ctx context.Context, key string, value []byte, ttl time.Duration) error { |
| 354 | return c.storeOperation(ctx, key, value, ttl, opSet, func(ctx context.Context, key string, value []byte, ttl time.Duration) error { |