Documentation
¶
Index ¶
- Variables
- type Cache
- func (c *Cache) Add(key string, value any, ttl time.Duration) (bool, error)
- func (c *Cache) Get(key string) (any, error)
- func (c *Cache) Keys(prefix string) []string
- func (c *Cache) Pop(key string) (any, error)
- func (c *Cache) Remove(keys ...string) error
- func (c *Cache) Set(key string, value any, ttl time.Duration) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotFound = errors.New("key not found")
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a generic cache implementation with support for time-to-live (TTL) expiration.
func New ¶
func New() *Cache
NewTTL creates a new TTLCache instance and starts a goroutine to periodically remove expired items every 5 seconds.
Click to show internal directories.
Click to hide internal directories.