You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
448 B

3 years ago
  1. package redis
  2. import (
  3. "context"
  4. "gitea.baoapi.com/root/stu_uuos/config"
  5. redisv8 "github.com/go-redis/redis/v8"
  6. "log"
  7. )
  8. var Rdb *redisv8.Client
  9. func Init() {
  10. cfg := config.GetConfig().Redis
  11. var err error
  12. Rdb = redisv8.NewClient(
  13. &redisv8.Options{
  14. Addr: cfg.Addr,
  15. Password: "",
  16. DB: 1,
  17. })
  18. _, err = Rdb.Ping(context.Background()).Result()
  19. if err != nil {
  20. log.Fatalf("redis error: %v\n", err)
  21. return
  22. }
  23. return
  24. }