From 57dd3969df2b866011ae39f3b86a149cfc11e7a6 Mon Sep 17 00:00:00 2001 From: samarthjuneja24 Date: Sat, 29 Oct 2022 15:16:07 +0530 Subject: [PATCH] saving integer as integer, keeping all other formats as string --- core/eval.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/eval.go b/core/eval.go index 0a035a25..4a5529ca 100644 --- a/core/eval.go +++ b/core/eval.go @@ -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)) + } return RESP_OK }