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
<PackageReference Include="TradeRouter.Net.Caching" Version="2.9.0" />
<PackageVersion Include="TradeRouter.Net.Caching" Version="2.9.0" />
<PackageReference Include="TradeRouter.Net.Caching" />
paket add TradeRouter.Net.Caching --version 2.9.0
#r "nuget: TradeRouter.Net.Caching, 2.9.0"
#:package TradeRouter.Net.Caching@2.9.0
#addin nuget:?package=TradeRouter.Net.Caching&version=2.9.0
#tool nuget:?package=TradeRouter.Net.Caching&version=2.9.0
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 | Versions 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. |
-
net10.0
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.14)
- TradeRouter.Net (>= 2.9.0)
-
net8.0
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.14)
- TradeRouter.Net (>= 2.9.0)
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 | 20 | 11/3/2026 |