Documentation ¶ Index ¶ Variables type Cache func New[T any](cfg Config) *Cache[T] func (c *Cache[T]) Cleanup() func (c *Cache[T]) Delete(key string) error func (c *Cache[T]) Drain() map[string]T func (c *Cache[T]) Get(key string) (T, error) func (c *Cache[T]) Set(key string, value T) error type Config Constants ¶ This section is empty. Variables ¶ View Source var ( ErrKeyNotFound = errors.New("key not found") ErrKeyExpired = errors.New("key expired") ) Functions ¶ This section is empty. Types ¶ type Cache ¶ type Cache[T any] struct { // contains filtered or unexported fields } func New ¶ func New[T any](cfg Config) *Cache[T] func (*Cache[T]) Cleanup ¶ func (c *Cache[T]) Cleanup() func (*Cache[T]) Delete ¶ added in v1.16.0 func (c *Cache[T]) Delete(key string) error func (*Cache[T]) Drain ¶ func (c *Cache[T]) Drain() map[string]T func (*Cache[T]) Get ¶ func (c *Cache[T]) Get(key string) (T, error) func (*Cache[T]) Set ¶ func (c *Cache[T]) Set(key string, value T) error type Config ¶ type Config struct { TTL time.Duration } Source Files ¶ View all Source files cache.goconfig.goerrors.go Click to show internal directories. Click to hide internal directories.