-
Notifications
You must be signed in to change notification settings - Fork 575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add config command #181
base: master
Are you sure you want to change the base?
add config command #181
Conversation
# Conflicts: # database/server.go
database/config.go
Outdated
if len(args)%2 != 0 { | ||
return protocol.MakeErrReply("ERR wrong number of arguments for 'config|set' command") | ||
} | ||
properties := config.CopyProperties() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不懂为什么需要 copy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
因为config set是原子性的,所以我希望拷贝一份配置对象,然后先在这个对象上进行修改,最后的时候再将原本的配置文件对象指向这个修改后的对象
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
因为线程可见性的原因,在没有使用 mutex 或 atomic 等并发原语的情况下是无法保证原子性的。建议了解一下 happens-before, 线程可见性和指令重拍等内容
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里我加了个mutex,或者可以给个别的思路嘛,如何保证同时多个配置时的原子性
database/config.go
Outdated
if len(args)%2 != 0 { | ||
return protocol.MakeErrReply("ERR wrong number of arguments for 'config|set' command") | ||
} | ||
properties := config.CopyProperties() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
因为线程可见性的原因,在没有使用 mutex 或 atomic 等并发原语的情况下是无法保证原子性的。建议了解一下 happens-before, 线程可见性和指令重拍等内容
No description provided.