demo modify

This commit is contained in:
Gordon
2022-02-11 16:25:28 +08:00
parent 609ec24c6a
commit a885d7f003
11 changed files with 183 additions and 313 deletions
+14
View File
@@ -7,6 +7,7 @@ import (
)
const (
registerAccountTempCode = "REGISTER_ACCOUNT_TEMP_CODE"
userIncrSeq = "REDIS_USER_INCR_SEQ:" // user incr seq
appleDeviceToken = "DEVICE_TOKEN"
userMinSeq = "REDIS_USER_MIN_SEQ:"
@@ -33,6 +34,19 @@ func (d *DataBases) Exec(cmd string, key interface{}, args ...interface{}) (inte
return con.Do(cmd, params...)
}
func (d *DataBases) JudgeAccountEXISTS(account string) (bool, error) {
key := registerAccountTempCode + account
return redis.Bool(d.Exec("EXISTS", key))
}
func (d *DataBases) SetAccountCode(account string, code, ttl int) (err error) {
key := registerAccountTempCode + account
_, err = d.Exec("Set", key, code, ttl)
return err
}
func (d *DataBases) GetAccountCode(account string) (string, error) {
key := userIncrSeq + account
return redis.String(d.Exec("GET", key))
}
//Perform seq auto-increment operation of user messages
func (d *DataBases) IncrUserSeq(uid string) (uint64, error) {