city.go 393 B

1234567891011121314151617181920212223
  1. package city
  2. import (
  3. "github.com/gomodule/redigo/redis"
  4. "miads/adslib/ads_redis"
  5. )
  6. func GetCityCode(city string) (int, error) {
  7. conn := ads_redis.RedisConn.Get()
  8. defer conn.Close()
  9. redisKey := "ads_city_" + city
  10. rsp, err := conn.Do("GET", redisKey)
  11. if err != nil {
  12. return 0, err
  13. }
  14. if rsp == nil {
  15. return 0, nil
  16. }
  17. cityCode, err := redis.Int(rsp, err)
  18. return cityCode, nil
  19. }