Documentation ¶
Index ¶
- func Load(s Store, c cache.Cacheable, ...) error
- func LoadWithBatchLoader(s Store, c cache.Cacheable, l BatchDataLoader, keys ...string) error
- type BatchDataLoader
- type DataSource
- func (s *DataSource) BatchLoadData(keys ...string) (map[string]interface{}, error)
- func (s *DataSource) Load(m Store, c cache.Cacheable, keys ...string) error
- func (s *DataSource) NewDataElement() interface{}
- func (s *DataSource) NewMapStoreLoader(c cache.Cacheable) *Loader
- func (s *DataSource) NewSyncMapStoreLoader(c cache.Cacheable) *Loader
- type Loader
- type MapStore
- type Store
- type SyncMapStore
- func (m *SyncMapStore) Delete(key string)
- func (m *SyncMapStore) Flush()
- func (m *SyncMapStore) Load(key string) (value interface{}, ok bool)
- func (m *SyncMapStore) LoadInterface(key string) interface{}
- func (m *SyncMapStore) Map() *sync.Map
- func (m *SyncMapStore) SetMap(smap *sync.Map)
- func (m *SyncMapStore) Store(key string, value interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Load ¶
func Load(s Store, c cache.Cacheable, loader func(...string) (map[string]interface{}, error), creator func() interface{}, keys ...string) error
Load load data by given key list into data store. Param s target data store. Param c map cache Param loader func by which data load. Param creator map element creator. Param keys key list to load Return any error if raised.
func LoadWithBatchLoader ¶
LoadWithBatchLoader load data by given key list into data store. Param s target data store. Param c map cache Param l BatchDataLoader Param keys key list to load Return any error if raised.
Types ¶
type BatchDataLoader ¶
type BatchDataLoader interface { // NewDataElement create empty data element. // Must return pointer of data. NewDataElement() interface{} //BatchLoadData load data by given keys to map of data pointers. // Return map of data pointers and any error if raised. BatchLoadData(...string) (map[string]interface{}, error) }
BatchDataLoader batch data loader interface
type DataSource ¶
type DataSource struct { // Creator empty createor. // Must return pointer of data. Creator func() interface{} //SourceLoader source loader which load data by given keys to map of data pointers. // Return map of data pointers and any error if raised. SourceLoader func(...string) (map[string]interface{}, error) }
DataSource data store datasource
func (*DataSource) BatchLoadData ¶
func (s *DataSource) BatchLoadData(keys ...string) (map[string]interface{}, error)
BatchLoadData load data by given keys to map of data pointers. Return map of data pointers and any error if raised.
func (*DataSource) Load ¶
Load load data by given keys to store with given cache Return any error if rasied.
func (*DataSource) NewDataElement ¶
func (s *DataSource) NewDataElement() interface{}
NewDataElement create empty data element. Must return pointer of data.
func (*DataSource) NewMapStoreLoader ¶
func (s *DataSource) NewMapStoreLoader(c cache.Cacheable) *Loader
NewMapStoreLoader create map store loader with given cache
func (*DataSource) NewSyncMapStoreLoader ¶
func (s *DataSource) NewSyncMapStoreLoader(c cache.Cacheable) *Loader
NewSyncMapStoreLoader create sync map store loader with given cache
type Loader ¶
type Loader struct { Cache cache.Cacheable Store Store BatchDataLoader BatchDataLoader }
Loader data store loader
func NewLoader ¶
func NewLoader(s Store, c cache.Cacheable, l BatchDataLoader) *Loader
NewLoader create new loader with given store,cache and batchlaoder
func NewMapLoader ¶
func NewMapLoader(c cache.Cacheable, l BatchDataLoader) *Loader
NewMapLoader create new loader with new MapStore,cache and batchlaoder
func NewSyncMapLoader ¶
func NewSyncMapLoader(c cache.Cacheable, l BatchDataLoader) *Loader
NewSyncMapLoader create new loader with new SyncMapStore,cache and batchlaoder
type MapStore ¶
type MapStore map[string]interface{}
MapStore store which stores value in map. You should confirm safe for concurrent by yourself.
func (*MapStore) LoadInterface ¶
LoadInterface Load load value with given key Return loaded value or nil if load fail
type Store ¶
type Store interface { // Load load value with given key // Return value and whether load successfully Load(key string) (value interface{}, ok bool) // Store store value with given key Store(key string, value interface{}) // Delete delete value from store with given key Delete(key string) // Flush flush store Flush() // LoadInterface Load load value with given key // Return loaded value or nil if load fail LoadInterface(key string) interface{} }
Store interface of data store
type SyncMapStore ¶
type SyncMapStore struct {
// contains filtered or unexported fields
}
SyncMapStore store which stores value in sync.map.
func NewSyncMapStore ¶
func NewSyncMapStore() *SyncMapStore
NewSyncMapStore create new sync.map store
func (*SyncMapStore) Delete ¶
func (m *SyncMapStore) Delete(key string)
Delete delete value from store with given key
func (*SyncMapStore) Load ¶
func (m *SyncMapStore) Load(key string) (value interface{}, ok bool)
Load load value with given key Return value and whether load successfully
func (*SyncMapStore) LoadInterface ¶
func (m *SyncMapStore) LoadInterface(key string) interface{}
LoadInterface Load load value with given key Return loaded value or nil if load fail
func (*SyncMapStore) SetMap ¶
func (m *SyncMapStore) SetMap(smap *sync.Map)
SetMap set sync map to store
func (*SyncMapStore) Store ¶
func (m *SyncMapStore) Store(key string, value interface{})
Store sotre value with given key