polywrap_uri_resolvers.resolvers.cache.resolution_result_cache_resolver module

This module contains the ResolutionResultCacheResolver.

class polywrap_uri_resolvers.resolvers.cache.resolution_result_cache_resolver.ResolutionResultCacheResolver(resolver_to_cache: UriResolver, cache: ResolutionResultCache, cache_errors: bool = False)[source]

Bases: UriResolver

An implementation of IUriResolver that caches the URI resolution result.

The URI resolution result can be a URI, IWrapPackage, Wrapper, or Error. Errors are not cached by default and can be cached by setting the cache_errors option to True.

Parameters:
  • resolver_to_cache (UriResolver) – The URI resolver to cache.

  • cache (ResolutionResultCache) – The resolution result cache.

  • cache_errors (bool) – Whether to cache errors.

cache: ResolutionResultCache

The resolution result cache.

cache_errors: bool

Whether to cache errors.

resolver_to_cache: UriResolver

The URI resolver to cache.

try_resolve_uri(uri: Uri, client: InvokerClient, resolution_context: UriResolutionContext) Uri | UriWrapper | UriPackage[source]

Try to resolve a URI to a wrap package, a wrapper, or a URI.

This method tries to resolve the URI with the resolver to cache. If the result is in the cache, it returns the cached result. If the result is not in the cache, it resolves the URI using the inner resolver and caches the result.

Parameters:
Returns:

The result of the resolution.

Return type:

UriPackageOrWrapper