server.go 507 B

1234567891011121314151617181920212223242526272829
  1. // Copyright 2019 getensh.com. All rights reserved.
  2. // Use of this source code is governed by getensh.com.
  3. package redis
  4. import "time"
  5. func (p *Redis) Time() (res time.Time, err error) {
  6. // 安全检查
  7. if p == nil {
  8. return res, errRedis
  9. }
  10. if p.cluster {
  11. // 客户端安全检查
  12. if p.cclient == nil {
  13. return res, errRedisCClient
  14. }
  15. return p.cclient.Time().Result()
  16. }
  17. // 客户端安全检查
  18. if p.client == nil {
  19. return res, errRedisClient
  20. }
  21. return p.client.Time().Result()
  22. }