clear-cache.go 755 B

1234567891011121314151617181920212223242526272829303132
  1. package http
  2. import (
  3. "go-common/library/ecode"
  4. bm "go-common/library/net/http/blademaster"
  5. "strconv"
  6. )
  7. // clearRoomCacheByRID删除room_id缓存的接口,防止缓存问题出现的bug
  8. func clearRoomCacheByRID(c *bm.Context) {
  9. params := c.Request.URL.Query()
  10. room := params.Get("room_id")
  11. roomID, err := strconv.ParseInt(room, 10, 64)
  12. if err != nil || roomID <= 0 {
  13. c.Set("output_data", "room_id is empty")
  14. c.JSONMap(map[string]interface{}{"message": "room_id is empty"}, ecode.RequestErr)
  15. c.Abort()
  16. return
  17. }
  18. err = srv.ClearRoomCacheByRID(c, roomID)
  19. if err != nil {
  20. c.JSONMap(map[string]interface{}{"message": err.Error()}, ecode.RequestErr)
  21. c.Abort()
  22. return
  23. }
  24. c.JSONMap(map[string]interface{}{"message": "ok"}, nil)
  25. }