diff --git a/README.md b/README.md index fb42d29..d7c7396 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,9 @@ go get github.com/TwinProduction/gocache ``` ```golang -cache := NewCache().WithMaxSize(1000).WithEvictionPolicy(gocache.LeastRecentlyUsed) +cache := gocache.NewCache().WithMaxSize(1000).WithEvictionPolicy(gocache.LeastRecentlyUsed) cache.Set("key", "value") value, ok := cache.Get("key") +cache.Delete("key") +cache.Count() ``` \ No newline at end of file diff --git a/gocache.go b/gocache.go index 3f30904..aa11b67 100644 --- a/gocache.go +++ b/gocache.go @@ -87,3 +87,9 @@ func (cache *Cache) Count() int { cache.mutex.Unlock() return count } + +func (cache *Cache) Clear() { + cache.mutex.Lock() + cache.entries = make(map[string]*Entry) + cache.mutex.Unlock() +}