Validate location existence, validate code pattern

This commit is contained in:
2024-06-09 18:44:26 -05:00
parent 87e7da60fa
commit 92849b83ba
2 changed files with 16 additions and 3 deletions

View File

@@ -4,6 +4,13 @@ import (
"fmt"
)
// LocationExists checks if a location identifier is valid (as known by the cache).
// Cache rarely will change, so this is a good way to check if a location is valid.
func LocationExists(location int64) bool {
_, ok := cachedLocationsMap[uint(location)]
return ok
}
func StoreCode(code string, location int64, member_id int) bool {
key := fmt.Sprintf("code:%d:%d", location, member_id)
already_set := db.Exists(key).Val() == 1