golang-im聊天
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

room_seq_repo.go 371 B

2 年之前
123456789101112131415161718192021
  1. package room
  2. import (
  3. "fmt"
  4. "gim/pkg/db"
  5. "gim/pkg/gerrors"
  6. )
  7. const RoomSeqKey = "room_seq:%d"
  8. type roomSeqRepo struct{}
  9. var RoomSeqRepo = new(roomSeqRepo)
  10. func (*roomSeqRepo) GetNextSeq(roomId int64) (int64, error) {
  11. num, err := db.RedisCli.Incr(fmt.Sprintf(RoomSeqKey, roomId)).Result()
  12. if err != nil {
  13. return 0, gerrors.WrapError(err)
  14. }
  15. return num, err
  16. }