修复normal读取数据panic问题

This commit is contained in:
2023-02-13 16:44:13 +08:00
parent 7713928d92
commit 8f30d99db4
3 changed files with 31 additions and 4 deletions

View File

@ -234,15 +234,15 @@ func (n *normal) Exist(key interface{}) bool {
return exist
}
// GetAll 读取全部数据使用的是原始数据深拷贝,避免获取到全部数据之后,直接读取导致并发读写
// GetAll 读取全部数据使用的是原始数据深拷贝
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 10:36 下午 2021/2/23
func (n *normal) GetAll() map[interface{}]interface{} {
result := make(map[interface{}]interface{})
n.lock.RLock()
defer n.lock.RUnlock()
n.RLock()
defer n.RUnlock()
for key, val := range n.data {
result[key] = val
}