Documentation ¶
Index ¶
- Constants
- func Exist(key string, args ...interface{}) bool
- func Get(key string, args ...interface{}) data.Value
- func Register(name string, f func(opts data.Map) (Provider, error))
- func Remove(key string, args ...interface{})
- func RemoveGroup(key string)
- func Set(value interface{}, key string, args ...interface{})
- type Cacher
- type ErrorHandling
- type KeyInfo
- type Keyer
- type Options
- type Provider
- type Value
Constants ¶
View Source
const PkgName = "auxo.cache"
Variables ¶
This section is empty.
Functions ¶
func RemoveGroup ¶
func RemoveGroup(key string)
Types ¶
type Cacher ¶
type Cacher interface { // Get returns cached value, the result is assured of not nil. Get(key string, args ...interface{}) data.Value Set(value interface{}, key string, args ...interface{}) Exist(key string, args ...interface{}) bool Remove(key string, args ...interface{}) RemoveGroup(key string) }
type ErrorHandling ¶
type ErrorHandling int
ErrorHandling defines how cache actions behave if the parse fails.
const ( ErrorSilent ErrorHandling = iota // Do nothing. ErrorLog // Write log with a descriptive error. ErrorPanic // Call panic with a descriptive error. )
These constants cause cache actions to behave as described if the parse fails.
func (*ErrorHandling) Unmarshal ¶
func (e *ErrorHandling) Unmarshal(i interface{}) (err error)
Unmarshal implements config.Unmarshaler interface.
type Provider ¶
type Provider interface { // Get returns cached value, provider should return data.Nil instead of nil when cache is invalid. Get(key string) (data.Value, error) Set(key string, value interface{}, expiry time.Duration) error Remove(key string) error Exist(key string) (bool, error) }
Provider is cache provider interface.
type Value ¶
type Value[T any] struct { TTL time.Duration Load func() (T, error) // contains filtered or unexported fields }
Value is a simple auto refresh cache hold.
func (*Value[T]) Get ¶
Get return cached value, it will return expired value if dirty is true and loading failed.
Click to show internal directories.
Click to hide internal directories.