package starmap import ( "b612.me/notify" ) func (kv *RemoteKv) getMap(data notify.SMsg) string { kv.kvmu.Lock() defer kv.kvmu.Unlock() val, ok := kv.kvmap.kvMapPro[data.Value] if !ok { data.Key = "error" data.Reply("key not exists") return "" } encodeData, err := encodeMap(val) if err != nil { data.Key = "error" data.Reply(err.Error()) return "" } return string(encodeData) } func (kv *RemoteKv) storeMap(data notify.SMsg) string { kv.kvmu.Lock() defer kv.kvmu.Unlock() recvData, err := decodeMap([]byte(data.Value)) if err != nil { data.Key = "error" data.Reply(err.Error()) return "" } err = kv.kvmap.StoreMap(recvData) if err != nil { data.Key = "error" data.Reply(err.Error()) return "" } return "ok" } func (kv *RemoteKv) deleteMap(data notify.SMsg) string { kv.kvmu.Lock() defer kv.kvmu.Unlock() delete(kv.kvmap.kvMapPro, data.Value) return "ok" }