MCPcopy Create free account
hub / github.com/Super-long/ChubbyGo / ChubbyGoMapGet

Method ChubbyGoMapGet

BaseServer/chubbyGoMap.go:55–78  ·  view source on GitHub ↗
(key string)

Source from the content-addressed store, hash-verified

53}
54
55func (hs *ChubbyGoConcurrentMap) ChubbyGoMapGet(key string) (string, bool) {
56 if hs.Flag == SyncMap {
57 Map := hs.MapEntry.Addr().Interface().(*sync.Map)
58
59 res, IsOk := Map.Load(key)
60 if IsOk {
61 return res.(string), true
62 } else {
63 return "", false
64 }
65 } else if hs.Flag == ConcurrentMap {
66 Map := hs.MapEntry.Addr().Interface().(*ConcurrentHashMap)
67
68 res, IsOk := Map.Get(key)
69 if IsOk {
70 return res.(string), true
71 } else {
72 return "", false
73 }
74 } else {
75 log.Println("ERROR : ChubbyGoMapSet -> No such situation.")
76 return "",false
77 }
78}
79
80func (hs *ChubbyGoConcurrentMap) ChubbyGoMapSet(key string, value string) {
81 // sync.map在拷贝以后失效

Callers 9

mainFunction · 0.80
GetMethod · 0.80
FastGetMethod · 0.80
acceptFromRaftDaemonMethod · 0.80
CompareAndSwapMethod · 0.80

Calls 1

GetMethod · 0.45