diff --git a/biz/handler/weather_and_earthquake/weather_and_earthquake_service.go b/biz/handler/weather_and_earthquake/weather_and_earthquake_service.go index eecc1b5..0599be2 100644 --- a/biz/handler/weather_and_earthquake/weather_and_earthquake_service.go +++ b/biz/handler/weather_and_earthquake/weather_and_earthquake_service.go @@ -110,6 +110,7 @@ func GetWeatherConditionByIPAddr(ctx context.Context, resp *weather_and_earthqua resp.LocationKey = key condition, err := data.GetWeatherCondition(ctx, key) if err == nil && len(condition) > 0 { + //logs.Info("缓存命中:" + key) resp.CurrentConditions = condition } else { condition, err = biz.GetCurrentConditions(key) diff --git a/configs/apps.yaml b/configs/apps.yaml index 196c239..0d78ad7 100644 --- a/configs/apps.yaml +++ b/configs/apps.yaml @@ -1,7 +1,9 @@ app_secrets: - - id: weatherQuery + - id: weatherQuery1 secret: secret1 - id: weatherQuery2 secret: secret2 - id: weatherQuery3 - secret: secret3 \ No newline at end of file + secret: secret3 + - id: weatherQuery4 + secret: secret4 \ No newline at end of file diff --git a/idl/WeatherAndEarthquake.thrift b/idl/WeatherAndEarthquake.thrift index 8508a76..1718318 100644 --- a/idl/WeatherAndEarthquake.thrift +++ b/idl/WeatherAndEarthquake.thrift @@ -3,7 +3,6 @@ namespace go weather_and_earthquake struct QueryReq { // 操作码 - // 0: 查最新地震信息。 // 1: 默认情况,通过ip地址查看天气。此时不需要其他参数。 // 2: 通过提供的 LocationKey 查看天气。需要提供 LocationKey。 // 3: 通过地名查看天气。需要提供 Addr。 @@ -13,7 +12,7 @@ struct QueryReq { } struct QueryResp { - // 0: 成功。如果是地震信息,就返回地震信息。如果是通过ip或者locationKey查询天气,就返回当前情况和预报。 + // 0: 成功。如果是通过ip或者locationKey查询天气,就返回当前情况和预报。 // 如果是通过地点查询,表示查到地点,并且只有一个,且通过这个key查询到了天气情况。 // -1: 参数错误 // -2: 请求头参数错误 @@ -26,7 +25,6 @@ struct QueryResp { 3: string Locations; 4: string CurrentConditions; 5: string DailyForecasts; - 6: string EarthquakeInformations; } service WeatherAndEarthquakeService { diff --git a/internal/data/weather_cache.go b/internal/data/weather_cache.go index 82e0738..1005ef2 100644 --- a/internal/data/weather_cache.go +++ b/internal/data/weather_cache.go @@ -31,7 +31,7 @@ func InitWeatherCache(ctx context.Context, data *config.Redis) error { // 设置某个地方的天气情况 func SetWeatherCondition(ctx context.Context, key, condition string) error { redis_key := fmt.Sprintf("%s-condition", key) - _, err := _redis.SetNX(ctx, redis_key, condition, _expire*time.Second).Result() + _, err := _redis.SetNX(ctx, redis_key, condition, _expire).Result() return err } @@ -51,7 +51,7 @@ func GetWeatherCondition(ctx context.Context, key string) (string, error) { // 设置某个地方的天气预报 func SetDailyForecasts(ctx context.Context, key, forecasts string) error { redis_key := fmt.Sprintf("%s-forecasts", key) - _, err := _redis.SetNX(ctx, redis_key, forecasts, _expire*time.Second).Result() + _, err := _redis.SetNX(ctx, redis_key, forecasts, _expire).Result() return err }