- begin
- if @forecast_cache.has_key?(loc) and
- Time.new - @forecast_cache[loc][:date] < 3600
- forecast = @forecast_cache[loc][:forecast]
- forecast_date = @forecast_cache[loc][:date]
- else
- begin
- l = LatLong.new
- f = Forecast.new(*l.get_lat_long(loc))
- forecast,forecast_date = f.forecast
- rescue => err
- m.reply err
- end
- end
+ begin
+ @cache_mutex.synchronize do
+ if @forecast_cache.has_key?(loc) and
+ Time.new - @forecast_cache[loc][:date] < 3600
+ forecast = @forecast_cache[loc][:forecast]