go-cache/remove.go

16 lines
229 B
Go

package gocache
func (cache *myCache) Remove(key string) error {
cache.mutex.Lock()
defer cache.mutex.Unlock()
_, exists := cache.items[key]
if !exists {
return ErrKeyNotFound
}
delete(cache.items, key)
return nil
}