redis.go 611 B

1234567891011121314151617181920212223242526272829303132
  1. package dao
  2. import (
  3. "context"
  4. "go-common/library/log"
  5. )
  6. const (
  7. _baseQsIdsKey = "v3_tc_bqs"
  8. )
  9. // SetQidCache set question id into question set
  10. func (d *Dao) SetQidCache(c context.Context, id int64) (err error) {
  11. var (
  12. key = _baseQsIdsKey
  13. conn = d.redis.Get(c)
  14. )
  15. defer conn.Close()
  16. if err = conn.Send("SET", key, id); err != nil {
  17. log.Error("conn.Send(SET, %s, %d) error(%v)", key, id, err)
  18. return
  19. }
  20. if err = conn.Flush(); err != nil {
  21. log.Error("conn.Flush error(%v)", err)
  22. return
  23. }
  24. if _, err = conn.Receive(); err != nil {
  25. log.Error("conn.Receive() error(%v)", err)
  26. }
  27. return
  28. }