Fix StoreCode bool return, add GetCode

This commit is contained in:
2023-12-12 03:10:34 -06:00
parent fdb2a48cf7
commit a991d9cdee

13
data.go
View File

@@ -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()
}