Documentation ¶
Overview ¶
Package gocache provides a data race-free cache implementation in Go.
Usage:
cache := gocache.NewCache(time.Minute * 2) // with 2 minutes interval cleaning cache.Set("key", "value", time.Minute) value, found := cache.Get("key") cache.Delete("key") cache.Clear() size := cache.Size()
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache represents a data race-free cache.
func (*Cache) Clear ¶
func (c *Cache) Clear()
Clear removes all items from the cache, making it empty.
func (*Cache) Delete ¶
Delete removes the specified key and its associated value from the cache. If the key does not exist in the cache, the function does nothing.
func (*Cache) Get ¶
Get retrieves the value associated with the specified key from the cache. It returns the value and a boolean indicating whether the key was found or not. If the key is found but the associated item has expired, the value will be nil and the boolean will be false.
Click to show internal directories.
Click to hide internal directories.