| 362 | } |
| 363 | |
| 364 | func (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 | |
| 377 | func (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 { |