INNER CODE UNIT · Go
New
metacontroller/metacontroller · pkg/cache/cache.go:38
func New[K comparable, V any](defaultExpiration, cleanupInterval time.Duration) *Cache[K, V] {
return &Cache[K, V]{
cache: zcache.New[K, V](defaultExpiration, cleanupInterval),
}
}
// Get an item from the cache.
//
// Returns the item or the zero value and a bool indicating whether the key is
// set.
func (c *Cache[K, V]) Get(key K) (V, bool) {
return c.cache.Get(key)
}
// Set a cache item, replacing any existing item.
func (c *Cache[K, V]) Set(key K, val V) {
c.cache.Set(key, val)
}