InMemoryRestApiClientCache
Ecng.Net
Represents an in-memory cache for REST API client responses.
构造函数
InMemoryRestApiClientCache
public InMemoryRestApiClientCache(TimeSpan timeout)
inMemoryRestApiClientCache = InMemoryRestApiClientCache(timeout)
Initializes a new instance of the InMemoryRestApiClientCache class with the specified timeout.
- timeout
- The duration after which a cached item expires.
InMemoryRestApiClientCache
public InMemoryRestApiClientCache(TimeSpan timeout, TimeProvider time)
inMemoryRestApiClientCache = InMemoryRestApiClientCache(timeout, time)
Initializes a new instance of the InMemoryRestApiClientCache class with the specified timeout.
- timeout
- How long a response outlives the last request for it.
- time
- The clock an item's age is measured on.
InMemoryRestApiClientCache
public InMemoryRestApiClientCache(TimeSpan timeout, TimeSpan maxAge, TimeProvider time)
inMemoryRestApiClientCache = InMemoryRestApiClientCache(timeout, maxAge, time)
Initializes a new instance of the InMemoryRestApiClientCache class.
- timeout
- How long a response outlives the last request for it.
- maxAge
- The oldest a response may be, however often it is requested.
- time
- The clock an item's age is measured on.
属性
MaxAge
public TimeSpan MaxAge { get; }
value = inMemoryRestApiClientCache.MaxAge
Gets the oldest a response may be, however often it is requested.
Timeout
public TimeSpan Timeout { get; }
value = inMemoryRestApiClientCache.Timeout
Gets how long a response outlives the last request for it.
方法
IsSupported
protected virtual bool IsSupported(HttpMethod method)
result = inMemoryRestApiClientCache.IsSupported(method)
Determines whether the specified HTTP method is supported for caching.
- method
- The HTTP method of the request.
返回值: True if the method is supported; otherwise, false.
ToKey
protected virtual ValueTuple<HttpMethod, string, object> ToKey(HttpMethod method, Uri uri, object body)
result = inMemoryRestApiClientCache.ToKey(method, uri, body)
Converts the provided HTTP method, URI, and body into a cache key.
- method
- The HTTP method of the request.
- uri
- The URI of the request.
- body
- The request body.
返回值: A tuple that represents the cache key.
字段
Cache
protected readonly TtlCache<ValueTuple<HttpMethod, string, object>, object> Cache
value = inMemoryRestApiClientCache.Cache
The cache that stores the cached items.