cache

package
v0.0.0-...-0e4f5d7 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const AddressLinkObjectIndex = "addressLinkHierarchy"
View Source
const PrimaryObjectIndex = "id"

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Init(indexSpecifier ...IndexSpecifier) error

	Add(objs ...interface{}) error
	Update(mutator ObjectMutator, objs ...interface{}) error
	Delete(objs ...interface{}) error
	DeleteByPrefix(idxName, keyPrefix string) error

	Get(idxName string, keyPrefix string, filter ObjectFilter) ([]interface{}, error)
	Dump() error

	GetKeyCreator(idxName string) (KeyCreator, error)
}

type IndexSpecifier

type IndexSpecifier struct {
	Name string
	memdb.Indexer
	AllowMissing bool
}

type KeyCreator

type KeyCreator func(obj interface{}) (bool, string, error)

type MemdbCache

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

func CreateObjectCache

func CreateObjectCache() (*MemdbCache, error)

func (*MemdbCache) Add

func (r *MemdbCache) Add(objs ...interface{}) error

func (*MemdbCache) Delete

func (r *MemdbCache) Delete(objs ...interface{}) error

func (*MemdbCache) DeleteByPrefix

func (r *MemdbCache) DeleteByPrefix(idxName, keyPrefix string) error

func (*MemdbCache) Dump

func (r *MemdbCache) Dump() error

func (*MemdbCache) Get

func (r *MemdbCache) Get(idxName string, keyPrefix string, filter ObjectFilter) ([]interface{}, error)

func (*MemdbCache) GetKeyCreator

func (r *MemdbCache) GetKeyCreator(idxName string) (KeyCreator, error)

func (*MemdbCache) Init

func (r *MemdbCache) Init(indexSpecifiers ...IndexSpecifier) error

func (*MemdbCache) Update

func (r *MemdbCache) Update(mutator ObjectMutator, objs ...interface{}) error

type ObjectFilter

type ObjectFilter = func(interface{}) (match bool, cont bool, e error)

ObjectFilters filter the objects return from a cache. return: - match, true if the object should be included in the results - cont, true if the traverse should continue - e in the event of a error preventing evaluation of the filter.

func And

func And(filters ...ObjectFilter) ObjectFilter

type ObjectMutator

type ObjectMutator = func(current interface{}) (replacement interface{}, e error)

ObjectMutator is used with Cache.Update function to mutate existing object(s) in the cache within a transaction. The ObjectMutator function receives the current value it uses to return a replacement Returning nil causes no change to be made for this value. Remaining objects will continue to be considered for update.

It is illegal for the updater function to mutate the object's key(s).

Jump to

Keyboard shortcuts

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