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

Method setSingleItem

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

Source from the content-addressed store, hash-verified

362}
363
364func (c *MemcachedClient) setSingleItem(key string, value []byte, ttl time.Duration) error {
365 ttlSeconds, ok := toSeconds(ttl)
366 if !ok {
367 return fmt.Errorf("%w: for set operation on %s %s", ErrInvalidTTL, key, ttl)
368 }
369
370 return c.client.Set(&memcache.Item{
371 Key: key,
372 Value: value,
373 Expiration: ttlSeconds,
374 })
375}
376
377func (c *MemcachedClient) Add(ctx context.Context, key string, value []byte, ttl time.Duration) error {
378 return c.storeOperation(ctx, key, value, ttl, opAdd, func(ctx context.Context, key string, value []byte, ttl time.Duration) error {

Callers 2

SetAsyncMethod · 0.95
SetMethod · 0.95

Calls 3

toSecondsFunction · 0.85
ErrorfMethod · 0.80
SetMethod · 0.65

Tested by

no test coverage detected