dao.go 581 B

12345678910111213141516171819202122232425262728293031
  1. package redis
  2. import (
  3. "go-common/app/job/main/videoup-report/conf"
  4. "go-common/library/cache/redis"
  5. )
  6. // Dao is redis dao.
  7. type Dao struct {
  8. c *conf.Config
  9. redis *redis.Pool
  10. secondary *redis.Pool
  11. }
  12. // New new a archive dao.
  13. func New(c *conf.Config) (d *Dao) {
  14. d = &Dao{
  15. c: c,
  16. redis: redis.NewPool(c.Redis.Track.Config),
  17. secondary: redis.NewPool(c.Redis.Secondary.Config),
  18. }
  19. return d
  20. }
  21. // Close close the redis connection
  22. func (d *Dao) Close() (err error) {
  23. if err = d.secondary.Close(); err != nil {
  24. return
  25. }
  26. return d.redis.Close()
  27. }