cache.go
func (c *cache) Add(k string, x interface{}, d time.Duration) error {
	c.mu.Lock()
	_, found := c.get(k)
	if found {
		c.mu.Unlock()
		return fmt.Errorf("Item %s already exists", k)
	}
	c.set(k, x, d)
	c.mu.Unlock()
	return nil
}
func (c *cache) Add(k string, x interface{}, d time.Duration) error {
	c.mu.Lock()
	_, found := c.get(k)
	if found {
		c.mu.Unlock()
		return fmt.Errorf("Item %s already exists", k)
	}
	c.set(k, x, d)
	c.mu.Unlock()
	return nil
}
func ( c * cache ) Add ( k string , x interface { } , d time . Duration ) error { c . mu . Lock ( ) _ , found := c . get ( k ) if found { c . mu . Unlock ( ) return fmt . Errorf ( " " , k ) } c . set ( k , x , d ) c . mu . Unlock ( ) return nil }
// Add an item to the cache only if an item doesn't already exist for the given
// key, or if the existing item has expired. Returns an error otherwise.
Add an item to the cache only if an item doesn t already exist for the given key or if the existing item has expired . Returns an error otherwise .