redis.go 360 B

123456789101112131415161718
  1. package dao
  2. import (
  3. "context"
  4. "go-common/library/log"
  5. )
  6. // pingRedis ping redis.
  7. func (d *Dao) pingRedis(c context.Context) (err error) {
  8. conn := d.redis.Get(c)
  9. defer conn.Close()
  10. if _, err = conn.Do("SET", "PING", "PONG"); err != nil {
  11. PromError("redis: ping remote")
  12. log.Error("remote redis: conn.Do(SET,PING,PONG) error(%v)", err)
  13. }
  14. return
  15. }