etcd-0x03-互斥锁读写文件

1
2
3
4
5
6
7
func (s *kvstore) getSnapshot() ([]byte, error) {
// 我在raft-py中时考虑过共享文件安全性 etcd用的就是读写锁 保证 读写互斥 读时不写 我以为是COW的方案保证性能呢
s.mu.RLock()
defer s.mu.RUnlock()
// map序列化json
return json.Marshal(s.kvStore)
}

etcd-0x03-互斥锁读写文件
https://bannirui.github.io/2025/06/06/etcd/etcd-0x03-互斥锁读写文件/
作者
dingrui
发布于
2025年6月6日
许可协议