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.
 
 
 
 

22 lines
377 B

  1. package room
  2. import (
  3. "egg-im/pkg/db"
  4. "egg-im/pkg/gerrors"
  5. "fmt"
  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. }