Skip to content
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

Removed a redundant check of ttl in setcmd #1539

Merged

Conversation

cheniujh
Copy link
Collaborator

(这个pr前面不小心被我操作分支的时候删了,现在再提一下)
1.执行set key value ex/px sec/ms 命令时,会对ttl进行两次非负检查:
第一次:setcmd的Doinitial函数中,如果set命令带了ex/px则会判断ttl是否非负
image

第二次:在带有ex/px执行set时,setcmd的Do方法最后是调用partition->db()->Setex方法,在这个方法内部会进行ttl非负检查:
image
image
为什么选择移除Doinitial中的非负检查,而不是移除setex函数中的:因为像"setex key seconds value"这样的命令在Doinitial中没有做ttl的非负检查(依赖于Setex方法中的ttl非负检查)

2.在一个被高频执行的函数中(Docmd函数),疑似存在不必要的动态类型转换(先把父类指针转子类传递给SetConn方法,但是SetConn的形参是父类指针的类型,所以又会隐式转换回去,平白多了2次没有意义的转换?)
image
image

当然,上面第2点只是我个人的看法,只是我个人没有看出这个转换有别的用处,如有错误,还请指正。

(when exec cmd like "set k v ex/px 10", non-negetive check of ttl will be done in function "RedisStrings::Setex", no need of doing it in "SetCmd::DoInitial").
2.removed an unnecessary dynamic cast.
@AlexStocks AlexStocks merged commit 27ae606 into OpenAtomFoundation:unstable May 25, 2023
bigdaronlee163 pushed a commit to bigdaronlee163/pika that referenced this pull request Jun 8, 2024
(when exec cmd like "set k v ex/px 10", non-negetive check of ttl will be done in function "RedisStrings::Setex", no need of doing it in "SetCmd::DoInitial").
2.removed an unnecessary dynamic cast.

Co-authored-by: cjh <[email protected]>
cheniujh added a commit to cheniujh/pika that referenced this pull request Sep 24, 2024
(when exec cmd like "set k v ex/px 10", non-negetive check of ttl will be done in function "RedisStrings::Setex", no need of doing it in "SetCmd::DoInitial").
2.removed an unnecessary dynamic cast.

Co-authored-by: cjh <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants