seq pull change

This commit is contained in:
Gordon
2021-10-26 10:59:59 +08:00
parent 90cde99f06
commit c9f326c722
3 changed files with 42 additions and 20 deletions

View File

@@ -9,6 +9,7 @@ const (
userIncrSeq = "REDIS_USER_INCR_SEQ:" // user incr seq
appleDeviceToken = "DEVICE_TOKEN"
lastGetSeq = "LAST_GET_SEQ"
userMinSeq = "REDIS_USER_Min_SEQ:"
)
func (d *DataBases) Exec(cmd string, key interface{}, args ...interface{}) (interface{}, error) {
@@ -37,12 +38,25 @@ func (d *DataBases) IncrUserSeq(uid string) (int64, error) {
return redis.Int64(d.Exec("INCR", key))
}
//获取最新的seq
func (d *DataBases) GetUserSeq(uid string) (int64, error) {
//获取最大的Seq
func (d *DataBases) GetUserMaxSeq(uid string) (int64, error) {
key := userIncrSeq + uid
return redis.Int64(d.Exec("GET", key))
}
//设置用户最小的seq
func (d *DataBases) SetUserMinSeq(uid string) (err error) {
key := userMinSeq + uid
_, err = d.Exec("SET", key)
return err
}
//获取最小的Seq
func (d *DataBases) GetUserMinSeq(uid string) (int64, error) {
key := userMinSeq + uid
return redis.Int64(d.Exec("GET", key))
}
//存储苹果的设备token到redis
func (d *DataBases) SetAppleDeviceToken(accountAddress, value string) (err error) {
key := appleDeviceToken + accountAddress