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

saving integer as integer, keeping all other formats as string #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion core/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,14 @@ func evalSET(args []string) []byte {
return Encode(errors.New("ERR syntax error"), false)
}
}
valueInt, valueIntOrErr := strconv.ParseInt(value, 10, 64)

// putting the k and value in a Hash Table
Put(key, NewObj(value, exDurationMs, oType, oEnc))
if valueIntOrErr == nil {
Put(key, NewObj(valueInt, exDurationMs, oType, oEnc))
} else {
Put(key, NewObj(value, exDurationMs, oType, oEnc))
}
Comment on lines +70 to +77
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we not check this while we are deducing the type and encoding? Doing strconv again is inefficient.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would have to make the deduce encoding method more specific for int64 usecases. It will have to return 4 params then instead of the existing two. One with the integer value and the other the err value of parseInt. And this will start bloating when more data types are added

return RESP_OK
}

Expand Down