Documentation
¶
Index ¶
- Constants
- Variables
- func Add(key string, prefix string, data any, expiration time.Duration) error
- func Delete(key string, prefix string)
- func Flush()
- func Get[T any](key string, prefix string) *T
- func GetValue[T any](key string, prefix string) (T, bool)
- func ListByPrefix[T any](prefix string) []*T
- func ListValuesByPrefix[T any](prefix string) []T
- func NewCache(opts *Options)
- func Set(key string, prefix string, data any, expiration time.Duration)
- func SetValue[T any](key string, prefix string, data T, expiration time.Duration)
- type Options
Constants ¶
View Source
const ( DefaultExpiration = 12 * time.Hour DefaultCleanupInterval = 10 * time.Minute NoExpiration = cache.NoExpiration ShortExpiration = 5 * time.Minute OneHourExpiration = 1 * time.Hour //prefixes PrefixDefault = "default:" PrefixConnection = "connection:" PrefixNode = "node:" PrefixThread = "thread:" )
Variables ¶
View Source
var ErrCacheAlreadyExists = errors.New("cache already exists")
Functions ¶
func GetValue ¶
GetValue returns a copy of the value stored under id/prefix. It accepts both T and *T in the cache (so mixed entries after migration still work). Second return is false if not found or type mismatch.
func ListByPrefix ¶
func ListValuesByPrefix ¶
ListValuesByPrefix returns copies of all values in the shard with the given prefix. Accepts both T and *T in the cache (so mixed entries after migration still work).
Types ¶
Click to show internal directories.
Click to hide internal directories.