cache

package
v2.3.20181123+incompat... Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2018 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Add(obj interface{}) error
	Update(obj interface{}) error
	Delete(obj interface{}) error
	List() []interface{}
	Get(string) (item interface{}, err error)
	Start(<-chan struct{})

	Reload(keys []string) (items []interface{}, err error)
	ReloadAll() (items []interface{}, err error)
	WaitForReady()
}

func NewCache

func NewCache(kind string, item CachedItem) Cache

type CacheGroup

type CacheGroup interface {
	Run()
	Get(string) (Cache, error)
}

type CachedItem

type CachedItem interface {
	TTL() time.Duration
	Name() string
	Period() time.Duration
	Update(keys []string) ([]interface{}, error)
	Load() ([]interface{}, error)
	Key(obj interface{}) (string, error)
	GetUpdate(d []interface{}) ([]string, error)
}

func NewCacheItem

func NewCacheItem(name string, ttl, period time.Duration,
	keyf expirationcache.KeyFunc,
	update UpdateFunc, load LoadFunc,
	getUpdate GetUpdateFunc,
) CachedItem

NewCacheItem new a Item implement CachedItem interface

type GetUpdateFunc

type GetUpdateFunc func(d []interface{}) ([]string, error)

type GroupManager

type GroupManager struct {
	Group map[string]Cache
	// contains filtered or unexported fields
}

func NewGroupManager

func NewGroupManager(kind string, items []CachedItem, ch <-chan struct{}) *GroupManager

func (*GroupManager) Get

func (m *GroupManager) Get(name string) (Cache, error)

func (*GroupManager) Run

func (m *GroupManager) Run()

type Item

type Item struct {
	// contains filtered or unexported fields
}

Item implement CachedItem interface

func (*Item) GetUpdate

func (h *Item) GetUpdate(d []interface{}) ([]string, error)

func (*Item) Key

func (h *Item) Key(obj interface{}) (string, error)

func (*Item) Load

func (h *Item) Load() ([]interface{}, error)

func (*Item) Name

func (h *Item) Name() string

func (*Item) Period

func (h *Item) Period() time.Duration

func (*Item) TTL

func (h *Item) TTL() time.Duration

func (*Item) Update

func (h *Item) Update(ids []string) ([]interface{}, error)

type LoadFunc

type LoadFunc func() ([]interface{}, error)

type UpdateFunc

type UpdateFunc func([]string) ([]interface{}, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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