mirror of
https://github.com/JKorf/CryptoExchange.Net.git
synced 2026-10-04 02:11:11 +00:00
Fixed caching issue for auth requests
This commit is contained in:
@@ -198,7 +198,7 @@ namespace CryptoExchange.Net.Clients
|
|||||||
string? cacheKey = null;
|
string? cacheKey = null;
|
||||||
if (ShouldCache(definition))
|
if (ShouldCache(definition))
|
||||||
{
|
{
|
||||||
cacheKey = definition.FullUrl + definition + uriParameters?.ToFormData();
|
cacheKey = GetCacheKey(definition, uriParameters);
|
||||||
_logger.CheckingCache(cacheKey);
|
_logger.CheckingCache(cacheKey);
|
||||||
var cachedValue = _cache.Get(cacheKey, ClientOptions.CachingMaxAge);
|
var cachedValue = _cache.Get(cacheKey, ClientOptions.CachingMaxAge);
|
||||||
if (cachedValue != null)
|
if (cachedValue != null)
|
||||||
@@ -800,6 +800,13 @@ namespace CryptoExchange.Net.Clients
|
|||||||
&& definition.Method == HttpMethod.Get
|
&& definition.Method == HttpMethod.Get
|
||||||
&& !definition.PreventCaching;
|
&& !definition.PreventCaching;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Produce a unique cache key for the request based on the request definition and parameters.
|
||||||
|
/// </summary>
|
||||||
|
protected virtual string GetCacheKey(RequestDefinition definition, Parameters? parameters)
|
||||||
|
{
|
||||||
|
return definition.FullUrl + definition + parameters?.ToFormData();
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public virtual void SetOptions(UpdateOptions options)
|
public virtual void SetOptions(UpdateOptions options)
|
||||||
@@ -889,6 +896,12 @@ namespace CryptoExchange.Net.Clients
|
|||||||
|
|
||||||
ApiCredentials = (TApiCredentials?)options.ApiCredentials?.Copy() ?? ApiCredentials;
|
ApiCredentials = (TApiCredentials?)options.ApiCredentials?.Copy() ?? ApiCredentials;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override string GetCacheKey(RequestDefinition definition, Parameters? parameters)
|
||||||
|
{
|
||||||
|
return definition.FullUrl + definition + parameters?.ToFormData() + GetAuthenticationProvider()?.Key;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
Reference in New Issue
Block a user