dao.go 528 B

12345678910111213141516171819202122232425262728293031323334
  1. package track
  2. import (
  3. "time"
  4. "go-common/app/admin/main/videoup/conf"
  5. "go-common/library/cache/redis"
  6. "go-common/library/database/sql"
  7. )
  8. // Dao is track dao.
  9. type Dao struct {
  10. c *conf.Config
  11. // db
  12. db *sql.DB
  13. // redis
  14. redis *redis.Pool
  15. expire int32
  16. }
  17. var (
  18. d *Dao
  19. )
  20. // New new a dao.
  21. func New(c *conf.Config) (d *Dao) {
  22. d = &Dao{
  23. c: c,
  24. db: sql.NewMySQL(c.DB.Archive),
  25. redis: redis.NewPool(c.Redis.Track.Config),
  26. expire: int32(time.Duration(c.Redis.Track.Expire) / time.Second),
  27. }
  28. return d
  29. }