Documentation
¶
Index ¶
- Constants
- type CacheTable
- func (table *CacheTable) Add(key string, lifeSpan time.Duration, data any) *CachedItem
- func (table *CacheTable) Clear()
- func (table *CacheTable) Delete(key string) (*CachedItem, error)
- func (table *CacheTable) Fetch(key string, f func() (any, error)) (any, error)
- func (table *CacheTable) Value(key string, args ...any) (any, error)
- type CachedItem
- type ErrNotFound
Constants ¶
View Source
const ( MIN_CACHE_LIFESPAN = 10 * time.Second DEFAULT_CACHE_LIFESPAN = 60 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheTable ¶
func NewCacheTable ¶
func NewCacheTable() *CacheTable
func (*CacheTable) Add ¶
func (table *CacheTable) Add(key string, lifeSpan time.Duration, data any) *CachedItem
Add a CachedItem to the CacheTable without any specific loader
func (*CacheTable) Delete ¶
func (table *CacheTable) Delete(key string) (*CachedItem, error)
Remove a specific CachedItem
type CachedItem ¶
func NewCachedItem ¶
func (*CachedItem) Fetch ¶
func (item *CachedItem) Fetch(f func() (any, error)) (any, error)
Get the item saved data or fetch it with the given func
func (*CachedItem) SetData ¶
func (item *CachedItem) SetData(data any)
Unused for now: Manually set a cached item data.
func (*CachedItem) SetDataLoader ¶
func (item *CachedItem) SetDataLoader(f func(...any) (any, error))
Unused for now: Define a data loader for the item
type ErrNotFound ¶
type ErrNotFound string
func (ErrNotFound) Error ¶
func (e ErrNotFound) Error() string
Click to show internal directories.
Click to hide internal directories.