Skip to content

Commit 322b25e

Browse files
committed
refactor(CONFIG): Refactored CONFIG command code
Signed-off-by: Ankush Chavan <cankush625@gmail.com>
1 parent c996e93 commit 322b25e

3 files changed

Lines changed: 5 additions & 2 deletions

File tree

common/constants.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const Set = "SET"
1212
const Expire = "EXPIRE"
1313
const Del = "DEL"
1414
const Keys = "KEYS"
15-
const ConfigCmd = "CONFIG"
15+
const Config = "CONFIG"
1616

1717
// Command Args
1818
// Expiration Args

db/expiry.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ const (
2020
func StartActiveExpiry() {
2121
go func() {
2222
for {
23+
// A fresh ticker is created on every iteration so that changes to hz
24+
// via CONFIG SET take effect on the next cycle without a restart.
25+
// Reusing a single ticker would lock in the interval set at startup.
2326
interval := ServerConfig.CleanupInterval()
2427
ticker := time.NewTicker(interval)
2528
<-ticker.C

exc/command_executor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func ExecuteCommand(command common.Cmd) ([]byte, error) {
2626
return cmd.Del(command)
2727
case common.Keys:
2828
return cmd.Keys(command)
29-
case common.ConfigCmd:
29+
case common.Config:
3030
return cmd.ConfigCmd(command)
3131
}
3232
return []byte("-unsupported command\r\n"), UnsupportedCommand

0 commit comments

Comments
 (0)