(ctx context.Context, key string, value []byte, ttl time.Duration)
| 556 | } |
| 557 | |
| 558 | func (c *MemcachedClient) CompareAndSwap(ctx context.Context, key string, value []byte, ttl time.Duration) error { |
| 559 | return c.storeOperation(ctx, key, value, ttl, opCompareAndSwap, func(ctx context.Context, key string, value []byte, ttl time.Duration) error { |
| 560 | select { |
| 561 | case <-ctx.Done(): |
| 562 | return ctx.Err() |
| 563 | default: |
| 564 | ttlSeconds, ok := toSeconds(ttl) |
| 565 | if !ok { |
| 566 | return fmt.Errorf("%w: for compare-and-swap operation on %s %s", ErrInvalidTTL, key, ttl) |
| 567 | } |
| 568 | |
| 569 | return c.client.CompareAndSwap(&memcache.Item{ |
| 570 | Key: key, |
| 571 | Value: value, |
| 572 | Expiration: ttlSeconds, |
| 573 | }) |
| 574 | } |
| 575 | }) |
| 576 | } |
| 577 | |
| 578 | func (c *MemcachedClient) FlushAll(ctx context.Context) error { |
| 579 | var err error |
nothing calls this directly
no test coverage detected