cache

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2018 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Index

type Index map[string]sets.String

Index maps the indexed value to a set of keys in the cache that match on that value

type IndexFunc

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

IndexFunc knows how to provide an indexed value for an object.

type Indexer

type Indexer interface {
	// Retrieve list of objects that match on the named indexing function
	Index(indexName string, obj interface{}) ([]interface{}, error)

	// ListIndexFuncValues returns the list of generated values of an Index func
	ListIndexFuncValues(indexName string) []string

	// ByIndex lists object that match on the named indexing function with the exact key
	ByIndex(indexName, indexKey string) ([]interface{}, error)

	// ByMultipleIndex lists object that match on named list indexing function with the exact key
	ByMultipleIndex(indexKV map[string][]string) ([]interface{}, error)

	// GetIndexer return the indexers
	GetIndexers() Indexers

	// AddIndexers adds more indexers to this store.  If you call this after you already have data
	// in the store, the results are undefined.
	AddIndexers(newIndexers Indexers) error
}

Indexer implement index method for cache, matched values are `ObjectName` in the other word, Primary key for the object in cache.

type Indexers

type Indexers map[string]IndexFunc

Indexers maps a name to a IndexFunc

type Indices

type Indices map[string]Index

Indices maps a name to an Index

type LocalCache

type LocalCache struct {
	ExpireTtl    time.Duration
	OutOfDateTtl time.Duration
	// contains filtered or unexported fields
}

func NewLocalCache

func NewLocalCache(indexers Indexers, indices Indices, outOfDateTtl time.Duration, expireTtl time.Duration) *LocalCache

func (*LocalCache) Add

func (lc *LocalCache) Add(objectName, objectType string, objectBody interface{}, lockFree bool) error

func (*LocalCache) AddIndexers

func (lc *LocalCache) AddIndexers(newIndexers Indexers) error

func (*LocalCache) ByIndex

func (lc *LocalCache) ByIndex(indexName, indexKey string) ([]interface{}, error)

ByIndex returns a list of items that match an exact value on the index function

func (*LocalCache) ByMultipleIndex

func (lc *LocalCache) ByMultipleIndex(indexKV map[string][]string) ([]interface{}, error)

ByMultipleIndex returns a list of items that both match the value for the index functions

func (*LocalCache) Data

func (lc *LocalCache) Data() map[string]*ObjectDef

func (*LocalCache) Delete

func (lc *LocalCache) Delete(objectName, objectType string, objectBody interface{}, lockFree bool) error

func (*LocalCache) GetIndexers

func (lc *LocalCache) GetIndexers() Indexers

func (*LocalCache) Index

func (lc *LocalCache) Index(indexName string, obj interface{}) ([]interface{}, error)

Index returns a list of items that match on the index function Index is thread-safe so long as you treat all items as immutable

func (*LocalCache) Init

func (lc *LocalCache) Init() error

func (*LocalCache) ListIndexFuncValues

func (lc *LocalCache) ListIndexFuncValues(indexName string) []string

func (*LocalCache) Reset

func (lc *LocalCache) Reset(data *map[string]*ObjectDef) error

func (*LocalCache) Serialize

func (lc *LocalCache) Serialize(object interface{}) (string, error)

func (*LocalCache) SerializedData

func (lc *LocalCache) SerializedData() (string, error)

func (*LocalCache) Update

func (lc *LocalCache) Update(objectName, objectType string, oldObjectBody, newObjectBody interface{}, lockFree bool) error

type ObjectBody

type ObjectBody interface{}

type ObjectDef

type ObjectDef struct {
	Body            ObjectBody
	Type            string
	CreatedUnixTime int64
	UpdatedUnixTime int64
	Deleted         bool
}

Jump to

Keyboard shortcuts

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