cache

package
v0.0.0-...-f9f6af2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 6, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

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

type CacheTable struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewCacheTable

func NewCacheTable() *CacheTable

func (*CacheTable) Add

func (table *CacheTable) Add(key string, lifeSpan time.Duration, data interface{}) *CachedItem

func (*CacheTable) Clear

func (table *CacheTable) Clear()

func (*CacheTable) Delete

func (table *CacheTable) Delete(key string) (*CachedItem, error)

func (*CacheTable) Fetch

func (table *CacheTable) Fetch(key string, f func() (interface{}, error)) (interface{}, error)

func (*CacheTable) Value

func (table *CacheTable) Value(key string, args ...interface{}) (interface{}, error)

type CachedItem

type CachedItem struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewCachedItem

func NewCachedItem(key string, lifeSpan time.Duration, data interface{}, loader func(...interface{}) (interface{}, error)) *CachedItem

func (*CachedItem) Fetch

func (item *CachedItem) Fetch(f func() (interface{}, error)) (interface{}, error)

func (*CachedItem) SetData

func (item *CachedItem) SetData(data interface{})

func (*CachedItem) SetDataLoader

func (item *CachedItem) SetDataLoader(f func(...interface{}) (interface{}, error))

func (*CachedItem) Stop

func (item *CachedItem) Stop()

func (*CachedItem) Value

func (item *CachedItem) Value(args ...interface{}) (interface{}, error)

type ErrNotFound

type ErrNotFound string

func (ErrNotFound) Error

func (e ErrNotFound) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL