block.go 525 B

1234567891011121314151617181920212223242526272829303132
  1. package dao
  2. import (
  3. "context"
  4. "fmt"
  5. "go-common/library/cache/memcache"
  6. "github.com/pkg/errors"
  7. )
  8. func userKey(mid int64) (key string) {
  9. key = fmt.Sprintf("u_%d", mid)
  10. return
  11. }
  12. // DeleteUserBlockCache is.
  13. func (d *Dao) DeleteUserBlockCache(c context.Context, mid int64) (err error) {
  14. var (
  15. key = userKey(mid)
  16. conn = d.blockMemcache.Get(c)
  17. )
  18. defer conn.Close()
  19. if err = conn.Delete(key); err != nil {
  20. if err == memcache.ErrNotFound {
  21. return nil
  22. }
  23. err = errors.WithStack(err)
  24. return
  25. }
  26. return
  27. }