Skip to content

Commit

Permalink
Optimize the set command with the NX option, add the default waiting …
Browse files Browse the repository at this point in the history
…timeout and correct the aof check logic
  • Loading branch information
snower committed May 18, 2024
1 parent 973feec commit 9bf96e5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
3 changes: 3 additions & 0 deletions protocol/textcommand.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,9 @@ func (self *TextCommandConverter) ConvertTextSetCommand(textProtocol ITextProtoc
return nil, nil, err
}
}
if lockCommand.Flag&LOCK_FLAG_UPDATE_WHEN_LOCKED == 0 && lockCommand.Timeout == 0 && lockCommand.TimeoutFlag == 0 {
lockCommand.Timeout = 15
}
if lockCommand.Expried == 0 && lockCommand.ExpriedFlag == 0 {
lockCommand.Expried = 0x7fff
lockCommand.ExpriedFlag = EXPRIED_FLAG_UNLIMITED_EXPRIED_TIME | EXPRIED_FLAG_ZEOR_AOF_TIME | EXPRIED_FLAG_UPDATE_NO_RESET_EXPRIED_CHECKED_COUNT
Expand Down
11 changes: 6 additions & 5 deletions server/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -1386,11 +1386,12 @@ func (self *LockDB) AddExpried(lock *Lock) {
self.slock.Log().Errorf("Database long expried wait index error %d %d", lock.longWaitIndex, lock.expriedTime)
lock.longWaitIndex = 0
}
if !lock.isAof && lock.aofTime != 0xff {
if self.currentTime-lock.startTime >= int64(lock.aofTime) {
for i := uint8(0); i < lock.locked; i++ {
_ = lock.manager.PushLockAof(lock, 0)
}
}

if !lock.isAof && lock.aofTime != 0xff {
if self.currentTime-lock.startTime >= int64(lock.aofTime) {
for i := uint8(0); i < lock.locked; i++ {
_ = lock.manager.PushLockAof(lock, 0)
}
}
}
Expand Down

0 comments on commit 9bf96e5

Please sign in to comment.