(k string, x interface{}, d time.Duration)
| 84 | } |
| 85 | |
| 86 | func (c *cache) Add(k string, x interface{}, d time.Duration) error { |
| 87 | c.mu.Lock() |
| 88 | //check exit |
| 89 | _, found := c.get(k) |
| 90 | if found { |
| 91 | err := fmt.Errorf("Item:%s has already exit", k) |
| 92 | return err |
| 93 | } |
| 94 | //set |
| 95 | c.set(k, x, d) |
| 96 | c.mu.Unlock() |
| 97 | return nil |
| 98 | } |
| 99 | |
| 100 | func (c *cache) Replace(k string, x interface{}, d time.Duration) error { |
| 101 | c.mu.Lock() |
no test coverage detected