dao.go 610 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package redis
  2. import (
  3. "context"
  4. "go-common/app/admin/main/aegis/conf"
  5. "go-common/library/cache/redis"
  6. )
  7. // Dao dao
  8. type Dao struct {
  9. c *conf.Config
  10. cluster *redis.Pool
  11. netExpire int64
  12. }
  13. // New init mysql db
  14. func New(c *conf.Config) (dao *Dao) {
  15. dao = &Dao{
  16. c: c,
  17. cluster: redis.NewPool(c.Redis.Cluster),
  18. netExpire: int64(c.Redis.NetExpire),
  19. }
  20. if dao.netExpire == 0 {
  21. dao.netExpire = int64(1800) //30m
  22. }
  23. return
  24. }
  25. // Close close the resource.
  26. func (d *Dao) Close() {
  27. d.cluster.Close()
  28. }
  29. // Ping dao ping
  30. func (d *Dao) Ping(c context.Context) error {
  31. return nil
  32. }