From a991d9cdeee0cb863f8e2d35e9cf1cb595e546a1 Mon Sep 17 00:00:00 2001 From: Xevion Date: Tue, 12 Dec 2023 03:10:34 -0600 Subject: [PATCH] Fix StoreCode bool return, add GetCode --- data.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/data.go b/data.go index 7caca77..2f715c8 100644 --- a/data.go +++ b/data.go @@ -6,12 +6,13 @@ import ( func StoreCode(code string, location int64, member_id int) bool { key := fmt.Sprintf("code:%d:%d", location, member_id) - - val_exists := db.Exists(key).Val() + already_set := db.Exists(key).Val() == 1 db.Set(key, code, 0) - val := db.Get(code).Val() - fmt.Println(val, val_exists) - - return false + return already_set +} + +func GetCode(location int64, member_id int) string { + key := fmt.Sprintf("code:%d:%d", location, member_id) + return db.Get(key).Val() }