build-redis-from-scratch
build-redis-from-scratch copied to clipboard
May there is a concurrent problem in hgetall function?
Code
HSETsMu.RLock()
value, ok := HSETs[hash]
HSETsMu.RUnlock()
if !ok {
return Value{typ: "null"}
}
values := []Value{}
for k, v := range value {
values = append(values, Value{typ: "bulk", bulk: k})
values = append(values, Value{typ: "bulk", bulk: v})
}
Description
I think the value can't be handle out the locker, the write goroutine will affect the read operation. It doesn't a deep copy