Documentation ¶
Index ¶
- type CleanFunc
- type CloneFunc
- type HashStore
- type ListItem
- type ListStore
- type ListStoreImpl
- func (s *ListStoreImpl) ConditionRange(f StoreConditionRangeFunc) bool
- func (s *ListStoreImpl) Delete(key string)
- func (s *ListStoreImpl) Front() *ListItem
- func (s *ListStoreImpl) Get(key string) StoredObj
- func (s *ListStoreImpl) Keys() []string
- func (s *ListStoreImpl) Len() int
- func (s *ListStoreImpl) Range(f StoreRangeFunc)
- func (s *ListStoreImpl) Set(key string, obj StoredObj)
- func (s *ListStoreImpl) String() string
- func (s *ListStoreImpl) UpdateRawStore(store RawStore, cloneFunc CloneFunc, cleanFunc CleanFunc)
- type RawStore
- type RawStoreImpl
- func (s *RawStoreImpl) ConditionRange(f StoreConditionRangeFunc) bool
- func (s *RawStoreImpl) Delete(key string)
- func (s *RawStoreImpl) Get(key string) StoredObj
- func (s *RawStoreImpl) GetGeneration() int64
- func (s *RawStoreImpl) Keys() []string
- func (s *RawStoreImpl) Len() int
- func (s *RawStoreImpl) Range(f StoreRangeFunc)
- func (s *RawStoreImpl) ResetUpdatedSet()
- func (s *RawStoreImpl) Set(key string, obj StoredObj)
- func (s *RawStoreImpl) SetGeneration(generation int64)
- func (s *RawStoreImpl) String() string
- func (s *RawStoreImpl) UpdatedSet() sets.String
- type Store
- type StoreConditionRangeFunc
- type StoreRangeFunc
- type StoredObj
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 ¶
DefaultCleanFunc is to remove all the elements that no longer exist in the ListStore but are still in the RawStore.
type ListItem ¶
type ListItem struct { // StoreObj holds the real object. StoredObj // contains filtered or unexported fields }
------------------- ListItem -------------------
type ListStore ¶
ListStore defines the methods of ListStore. ATTENTION: We need to control the lock of this data structure at the upper level.
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) Keys ¶
func (s *ListStoreImpl) Keys() []string
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(int64) GetGeneration() int64 UpdatedSet() sets.String ResetUpdatedSet() }
RawStore defines the methods of RawStore. ATTENTION: We need to control the lock of this data structure at the upper level.
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. ATTENTION: We need to control the lock of this data structure at the upper level.
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() int64
func (*RawStoreImpl) Keys ¶
func (s *RawStoreImpl) Keys() []string
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 int64)
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 Keys() []string String() string Range(StoreRangeFunc) ConditionRange(StoreConditionRangeFunc) bool }
Store defines the field that the some-datastructure will hold if it needs generationstore. The Store field's real object is either ListStore or RawStore. ATTENTION: We need to control the lock of this data structure at the upper level.
type StoreConditionRangeFunc ¶
The return value of StoreConditionRangeFunc means whether to continue the traversal process.