mirror of
https://github.com/Xevion/r2park.git
synced 2025-12-13 14:12:37 -06:00
Validate location existence, validate code pattern
This commit is contained in:
7
data.go
7
data.go
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user