OpenWeatherMap.Cache 1.3.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package OpenWeatherMap.Cache --version 1.3.5
                    
NuGet\Install-Package OpenWeatherMap.Cache -Version 1.3.5
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OpenWeatherMap.Cache" Version="1.3.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OpenWeatherMap.Cache" Version="1.3.5" />
                    
Directory.Packages.props
<PackageReference Include="OpenWeatherMap.Cache" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add OpenWeatherMap.Cache --version 1.3.5
                    
#r "nuget: OpenWeatherMap.Cache, 1.3.5"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package OpenWeatherMap.Cache@1.3.5
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=OpenWeatherMap.Cache&version=1.3.5
                    
Install as a Cake Addin
#tool nuget:?package=OpenWeatherMap.Cache&version=1.3.5
                    
Install as a Cake Tool

OpenWeatherMap.Cache

An asynchronous .NET Standard library that allows you to fetch & cache current weather readings from the OpenWeatherMap API, with in-built resiliency that can extend the cache lifetime in case the API is unreachable.

Installation

The recommended means is to use NuGet, but you could also download the source code from here.

Choose the fetch mode

If the time elapsed since the last fetch for the given location exceeds the cache period but is within the resiliency period (i.e. still available in the cache), the API reported measured time in the cache value is sometimes more recent than the latest value fetched from the API.

With FetchMode.AlwaysUseLastMeasured, the value still available in the cache is returned. IMPORTANT: Frequent calls may impact your API usage.

With FetchMode.AlwaysUseLastMeasuredButExtendCache (default), the value still available in the cache is returned but in order to protect impact on your API usage, this setting updates the cache value's fetched date and extends the cache lifetime.

With FetchMode.AlwaysUseLastFetchedValue, the last fetched API result is returned anyway, even though it is being reported to be older by the API.

Initialization with Dependency Injection

In your Startup.cs (ConfigureServices):

services.AddOpenWeatherMapCache("[API KEY]", FetchMode.AlwaysUseLastMeasuredButExtendCache, 9_500, 300_000);

Then you can inject IOpenWeatherMapCache.

Initialization without Dependency Injection

Create your own instance:

var openWeatherMapCache = new OpenWeatherMapCache("[API KEY]", FetchMode.AlwaysUseLastMeasuredButExtendCache, 9_500, 300_000);
var location = new OpenWeatherMap.Cache.Location(47.6371, -122.1237);
var readings = await openWeatherMapCache.GetReadingsAsync(location);
if (readings.IsSuccessful)
{
	...
}
else
{
	var apiErrorCode = readings.Exception?.ApiErrorCode;
	var apiErrorMessage = readings.Exception?.ApiErrorMessage;
}

Usage in synchronous methods

var location = new OpenWeatherMap.Cache.Location(47.6371, -122.1237);
var readings = openWeatherMapCache.GetReadingsAsync(location).Result;
if (readings.IsSuccessful)
{
	...
}
else
{
	var apiErrorCode = readings.Exception?.ApiErrorCode;
	var apiErrorMessage = readings.Exception?.ApiErrorMessage;
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.3.1 70 1/14/2026
2.3.0 118 1/2/2026
2.2.1 194 12/13/2025
2.1.7 139 12/12/2025
2.1.5 122 12/12/2025
2.1.4 690 12/2/2025
2.1.3 213 11/23/2025
2.1.2 198 11/15/2025
2.1.1 938 10/4/2025
2.1.0 602 6/28/2025
2.0.4 192 6/28/2025
2.0.3 194 5/30/2025
2.0.2 177 5/30/2025
2.0.1 183 5/30/2025
2.0.0 238 4/19/2025
1.12.4 229 4/12/2025
1.12.2 1,221 11/22/2024
1.12.1 4,081 11/11/2024
1.12.0 255 10/13/2024
1.11.1 215 10/5/2024
1.11.0 417 8/20/2024
1.10.6 743 7/21/2024
1.10.5 285 7/10/2024
1.10.3 3,047 1/23/2024
1.10.2 282 1/15/2024
1.10.1 640 1/1/2024
1.9.13 274 12/30/2023
1.9.12 255 12/6/2023
1.9.11 264 12/3/2023
1.9.10 214 12/2/2023
1.9.9 546 10/11/2023
1.9.8 1,336 4/10/2023
1.9.7 334 4/7/2023
1.9.6 2,021 3/25/2023
1.9.5 346 3/25/2023
1.9.4 452 2/25/2023
1.9.3 737 2/13/2023
1.9.2 408 2/3/2023
1.9.1 463 1/29/2023
1.9.0 427 1/27/2023
1.8.9 445 1/26/2023
1.8.8 478 1/2/2023
1.8.7 442 12/29/2022
1.8.6 536 12/18/2022
1.8.5 453 12/16/2022
1.8.3 452 12/13/2022
1.8.2 459 12/12/2022
1.8.1 434 12/12/2022
1.8.0 479 12/3/2022
1.7.5 451 11/28/2022
1.7.4 576 11/26/2022
1.7.3 466 11/19/2022
1.7.2 2,904 11/13/2022
1.6.1 1,116 10/26/2022
1.6.0 544 10/23/2022
1.5.12 788 10/18/2022
1.5.11 568 10/16/2022
1.5.10 588 9/17/2022
1.5.9 903 6/29/2022
1.5.8 601 6/29/2022
1.5.7 618 6/18/2022
1.5.6 621 6/9/2022
1.5.5 599 5/15/2022
1.5.4 1,828 4/15/2022
1.5.3 1,192 3/13/2022
1.5.2 594 3/13/2022
1.5.1 597 3/11/2022
1.5.0 657 2/26/2022
1.4.10 1,002 1/26/2022
1.4.9 718 12/11/2021
1.4.8 473 11/27/2021
1.4.7 498 11/23/2021
1.4.5 479 11/22/2021
1.4.4 923 11/21/2021
1.4.3 558 11/14/2021
1.4.2 480 11/10/2021
1.4.1 493 11/7/2021
1.4.0 534 10/20/2021
1.3.5 1,890 6/20/2021
1.3.4 603 6/20/2021
1.3.3 671 12/26/2020
1.3.2 633 12/6/2020
1.3.1 656 11/30/2020
1.3.0 624 11/28/2020
1.2.1 717 11/27/2020
1.2.0 630 11/24/2020
1.1.1 668 11/23/2020
1.1.0 628 11/23/2020
1.0.5 646 11/22/2020
1.0.4 604 11/22/2020
1.0.3 610 11/22/2020
1.0.2 595 11/22/2020
1.0.1 604 11/22/2020
1.0.0 640 11/22/2020

Added the possibility to log the results to file.