mc_wallet.go 569 B

123456789101112131415161718192021222324252627282930
  1. package dao
  2. import (
  3. "context"
  4. "fmt"
  5. mc "go-common/library/cache/memcache"
  6. "go-common/library/log"
  7. )
  8. const (
  9. _walletMcKey = "wu:%d"
  10. )
  11. func mcKey(uid int64) string {
  12. return fmt.Sprintf(_walletMcKey, uid)
  13. }
  14. // DelWalletCache 删除等级缓存
  15. func (d *Dao) DelWalletCache(c context.Context, uid int64) (err error) {
  16. key := mcKey(uid)
  17. conn := d.mc.Get(c)
  18. defer conn.Close()
  19. if err = conn.Delete(key); err == mc.ErrNotFound {
  20. err = nil
  21. } else if err != nil {
  22. log.Error("[dao.mc_wallet|DelWalletCache] conn.Delete(%s) error(%v)", key, err)
  23. }
  24. return
  25. }