This pull request introduces caching to the RemotePathMappingService to improve performance and reduce database load. The main change is the addition of an in-memory cache for remote path mappings per download client, ensuring that frequent lookups and checks do not repeatedly query the database. The cache is properly invalidated on create, update, and delete operations to maintain consistency.
Caching enhancements:
- Added
IMemoryCachedependency toRemotePathMappingServiceand initialized it via constructor injection. - Implemented caching in
GetByClientIdAsyncusingGetOrCreateAsync, storing mapping lists per client for 60 seconds and ordering mappings by path length for specificity.
Cache invalidation:
- Evicted cached mapping lists for the affected client after create, update, or delete operations to ensure subsequent lookups are up-to-date. [1] [2] [3]
Refactoring to use cache:
- Updated
TranslatePathAsyncandRequiresTranslationAsyncto use the cached mappings viaGetByClientIdAsync, reducing unnecessary database queries for these operations. [1] [2]
Automated canary build