generationstore

package
v0.0.0-...-a3fd192 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2022 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CleanFunc

type CleanFunc func()

CleanFunc defines the cleanup function used in UpdateRawStore.

func DefaultCleanFunc

func DefaultCleanFunc(cache ListStore, snapshot RawStore) CleanFunc

type CloneFunc

type CloneFunc func(string, StoredObj)

CloneFunc defines the clone function used in UpdateRawStore.

type HashStore

type HashStore map[string]StoredObj

HashStore defines the data model used for traversal.

type ListItem

type ListItem struct {
	StoredObj
	// contains filtered or unexported fields
}

------------------- ListItem -------------------

func (*ListItem) Next

func (item *ListItem) Next() *ListItem

func (*ListItem) Obj

func (item *ListItem) Obj() StoredObj

type ListStore

type ListStore interface {
	Store
	Front() *ListItem
	UpdateRawStore(RawStore, CloneFunc, CleanFunc)
}

ListStore defines the methods of ListStore.

func NewListStore

func NewListStore() ListStore

type ListStoreImpl

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

ListStoreImpl implement the ListStore interface. We will store all the objects in hashmap and linked-list, and maintain the StoredObj's generation according to ListStoreImpl.generation. And the linked-list will be organized in descending order of generation.

func (*ListStoreImpl) ConditionRange

func (s *ListStoreImpl) ConditionRange(f StoreConditionRangeFunc) bool

func (*ListStoreImpl) Delete

func (s *ListStoreImpl) Delete(key string)

func (*ListStoreImpl) Front

func (s *ListStoreImpl) Front() *ListItem

func (*ListStoreImpl) Get

func (s *ListStoreImpl) Get(key string) StoredObj

func (*ListStoreImpl) HashStore

func (s *ListStoreImpl) HashStore() HashStore

func (*ListStoreImpl) Len

func (s *ListStoreImpl) Len() int

func (*ListStoreImpl) Range

func (s *ListStoreImpl) Range(f StoreRangeFunc)

func (*ListStoreImpl) Set

func (s *ListStoreImpl) Set(key string, obj StoredObj)

Set will update the ListItem if it has been existed, or create a new ListItem to hold it. The ListStoreImpl.generation will be updated and the ListItem will be moved to head.

func (*ListStoreImpl) String

func (s *ListStoreImpl) String() string

func (*ListStoreImpl) UpdateRawStore

func (s *ListStoreImpl) UpdateRawStore(store RawStore, cloneFunc CloneFunc, cleanFunc CleanFunc)

UpdateRawStore update RawStore according the generation. We will update the RawStore by linked-list firstly, and by RawStore.UpdatedSet. Finally refresh the RawStore.generation and do cleanup.

type RawStore

type RawStore interface {
	Store
	SetGeneration(uint64)
	GetGeneration() uint64
	UpdatedSet() sets.String
	ResetUpdatedSet()
}

RawStore defines the methods of RawStore.

func NewRawStore

func NewRawStore() RawStore

type RawStoreImpl

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

RawStoreImpl implement the RawStore interface. StoredObj will be stored in a raw hashmap, and RawStoreImpl.generation hold the max-generation of these items.

func (*RawStoreImpl) ConditionRange

func (s *RawStoreImpl) ConditionRange(f StoreConditionRangeFunc) bool

func (*RawStoreImpl) Delete

func (s *RawStoreImpl) Delete(key string)

func (*RawStoreImpl) Get

func (s *RawStoreImpl) Get(key string) StoredObj

func (*RawStoreImpl) GetGeneration

func (s *RawStoreImpl) GetGeneration() uint64

func (*RawStoreImpl) Len

func (s *RawStoreImpl) Len() int

func (*RawStoreImpl) Range

func (s *RawStoreImpl) Range(f StoreRangeFunc)

func (*RawStoreImpl) ResetUpdatedSet

func (s *RawStoreImpl) ResetUpdatedSet()

func (*RawStoreImpl) Set

func (s *RawStoreImpl) Set(key string, obj StoredObj)

func (*RawStoreImpl) SetGeneration

func (s *RawStoreImpl) SetGeneration(generation uint64)

func (*RawStoreImpl) String

func (s *RawStoreImpl) String() string

func (*RawStoreImpl) UpdatedSet

func (s *RawStoreImpl) UpdatedSet() sets.String

type Store

type Store interface {
	Get(string) StoredObj
	Set(string, StoredObj)
	Delete(string)
	Len() int
	Range(StoreRangeFunc)
	ConditionRange(StoreConditionRangeFunc) bool
	String() string
}

Store defines the field that the some-datastructure will hold if it need generatestore. The Store field's real object is either ListStore or RawStore.

type StoreConditionRangeFunc

type StoreConditionRangeFunc func(string, StoredObj) bool

type StoreRangeFunc

type StoreRangeFunc func(string, StoredObj)

type StoredObj

type StoredObj interface {
	GetGeneration() uint64
	SetGeneration(uint64)
}

StoredObj defines the methods that all the objects stored in the generationstore must have.

Jump to

Keyboard shortcuts

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