TradeRouter.Net.Caching 2.9.0

dotnet add package TradeRouter.Net.Caching --version 2.9.0
                    
NuGet\Install-Package TradeRouter.Net.Caching -Version 2.9.0
                    
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="TradeRouter.Net.Caching" Version="2.9.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TradeRouter.Net.Caching" Version="2.9.0" />
                    
Directory.Packages.props
<PackageReference Include="TradeRouter.Net.Caching" />
                    
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 TradeRouter.Net.Caching --version 2.9.0
                    
#r "nuget: TradeRouter.Net.Caching, 2.9.0"
                    
#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 TradeRouter.Net.Caching@2.9.0
                    
#: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=TradeRouter.Net.Caching&version=2.9.0
                    
Install as a Cake Addin
#tool nuget:?package=TradeRouter.Net.Caching&version=2.9.0
                    
Install as a Cake Tool

TradeRouter.Net.Caching

Caching for TradeRouter.Net road-route providers. CachingRoadRouteProvider wraps any IRoadRouteProvider and serves repeated road legs from a store, so the same pickup or delivery leg is routed once per time to live instead of once per movement.

DistributedRoadRouteCache keeps results in any IDistributedCache: Redis, SQL Server, PostgreSQL, or the in-memory cache for tests. Implement IRoadRouteCache to keep them somewhere else, such as a database table you want to query.

// The application registers the IDistributedCache it uses, for example
// services.AddStackExchangeRedisCache(...) or services.AddDistributedSqlServerCache(...).
var request = new MovementRequest
{
    Legs = plan.Legs.ToList(),
    RoadRouteProvider = new CachingRoadRouteProvider(
        new OsrmRoadRouteProvider(httpClient, osrmUri),
        new DistributedRoadRouteCache(distributedCache),
        new RoadRouteCacheOptions
        {
            Partition = configuration["RoadRouting:CachePartition"]!,
            TimeToLive = TimeSpan.FromDays(configuration.GetValue<int>("RoadRouting:CacheDays"))
        }),
    RoadRoutingMode = RoadRoutingMode.PreferNetworkThenEstimate
};

Successful routes are kept for TimeToLive from the time they were fetched. NoRoute and OutsideCoverage results are kept only when NegativeTimeToLive is set, and Unavailable results never. If the store fails, the leg is routed without it and OnCacheError is called.

The provider caches whatever the wrapped provider returns, so check that provider's terms before choosing a time to live. Google Maps Platform terms do not allow Routes API results from GoogleRoutesRoadRouteProvider to be cached.

See the TradeRouter.Net README for the full description.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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 is compatible.  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. 
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.9.0 0 11/3/2026