Documentation
¶
Overview ¶
Package cache provides methods and structs for caching data
Index ¶
Constants ¶
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface {
// Has returns true if cache contains data for given key
Has(key string) bool
// Size returns number of items in cache
Size() int
// Expired returns number of expired items in cache
Expired() int
// Set adds or updates item in cache
Set(key string, data any, expiration ...time.Duration) bool
// GetWithExpiration returns item from cache
Get(key string) any
// GetWithExpiration returns item expiration date
GetExpiration(key string) time.Time
// GetWithExpiration returns item from cache and expiration date or nil
GetWithExpiration(key string) (any, time.Time)
// Keys is an iterator over cache keys
Keys(yield func(k string) bool)
// All is an iterator over cache items
All(yield func(k string, v any) bool)
// Delete removes item from cache
Delete(key string) bool
// Invalidate deletes all expired records
Invalidate() bool
// Flush removes all data from cache
Flush() bool
// Stop stops janitor goroutine
Stop()
}
Cache is cache backend interface
Click to show internal directories.
Click to hide internal directories.