You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
starmap/prorw.go

49 lines
904 B
Go

package starmap
import (
"errors"
)
type StarMap interface {
GetName() string
}
type StarMapSample struct{}
func (sample StarMapSample) GetName() string {
return "starsample"
}
func GetMap(value StarMap) error {
return globalMap.GetMap(value)
}
func (m *StarMapKV) GetMap(value StarMap) error {
m.kvmuPro.RLock()
defer m.kvmuPro.RUnlock()
value, ok := m.kvMapPro[value.GetName()]
if !ok {
return errors.New("key not exists")
}
return nil
}
func StoreMap(value StarMap) error {
return globalMap.StoreMap(value)
}
func (m *StarMapKV) StoreMap(value StarMap) error {
m.kvmuPro.Lock()
defer m.kvmuPro.Unlock()
m.kvMapPro[value.GetName()] = value
return nil
}
func DeleteMap(value StarMap) error {
return globalMap.DeleteMap(value)
}
func (m *StarMapKV) DeleteMap(value StarMap) error {
m.kvmuPro.RLock()
defer m.kvmuPro.RUnlock()
delete(m.kvMapPro, value.GetName())
return nil
}