Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion samples/ConsoleApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
{
for (int i = 1; i <= 5; ++i)
{
Console.Write($"Try: {i}: {url} ");
Console.Write($"Attempt: {i}: {url} ");

var stopwatch = Stopwatch.StartNew();
var result = await httpClient.GetAsync(url);
Expand Down
6 changes: 3 additions & 3 deletions src/HttpClient.Cache/CacheDataExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

namespace HttpClient.Cache;

public static class CacheDataExtensions
internal static class CacheDataExtensions
{
public static byte[] Pack(this CacheData cacheData)
internal static byte[] Pack(this CacheData cacheData)
{
var json = JsonConvert.SerializeObject(cacheData);
var bytes = new byte[json.Length * sizeof(char)];
Expand All @@ -14,7 +14,7 @@ public static byte[] Pack(this CacheData cacheData)
return bytes;
}

public static CacheData? Unpack(this byte[] cacheData)
internal static CacheData? Unpack(this byte[] cacheData)
{
try
{
Expand Down
4 changes: 2 additions & 2 deletions src/HttpClient.Cache/CacheEntryExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
namespace HttpClient.Cache;

public static class CacheEntryExtensions
internal static class CacheEntryExtensions
{
public static ICacheEntry AddExpirationToken(this ICacheEntry entry, IChangeToken token)
internal static ICacheEntry AddExpirationToken(this ICacheEntry entry, IChangeToken token)
{
if (token == null)
{
Expand Down
2 changes: 1 addition & 1 deletion src/HttpClient.Cache/InMemory/Clock/SystemClock.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace HttpClient.Cache.InMemory.Clock;

public class SystemClock: ISystemClock
internal class SystemClock: ISystemClock
{
public DateTimeOffset UtcNow => DateTimeOffset.UtcNow;
}
2 changes: 1 addition & 1 deletion src/HttpClient.Cache/InMemory/MemoryCacheExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace HttpClient.Cache.InMemory;

public static class MemoryCacheExtensions
internal static class MemoryCacheExtensions
{
public static Task<bool> TryGetAsync(this IMemoryCache cache, string key, out CacheData? cacheData)
{
Expand Down
6 changes: 3 additions & 3 deletions src/HttpClient.Cache/InMemory/MemoryCacheOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace HttpClient.Cache.InMemory;

public class MemoryCacheOptions
{
public TimeSpan ExpirationScanFrequency { get; } = TimeSpan.FromMinutes(1.0);
public ISystemClock? Clock { get; set; }
public TimeSpan ExpirationScanFrequency { get; set; } = TimeSpan.FromSeconds(1.0);

public ISystemClock Clock { get; set; } = new SystemClock();
}
11 changes: 4 additions & 7 deletions src/HttpClient.Cache/Utils/HttpStatusCodeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace HttpClient.Cache.Utils;

public static class HttpStatusCodeExtensions
internal static class HttpStatusCodeExtensions
{
public static TimeSpan GetAbsoluteExpirationRelativeToNow(this HttpStatusCode statusCode,
IDictionary<HttpStatusCode, TimeSpan> mapping)
Expand All @@ -13,11 +13,8 @@ public static TimeSpan GetAbsoluteExpirationRelativeToNow(this HttpStatusCode st
}

var code = (int)statusCode;
if (mapping.TryGetValue((HttpStatusCode)(Math.Floor(code / 100.0) * 100), out expiration))
{
return expiration;
}

return TimeSpan.FromDays(1);
return mapping.TryGetValue((HttpStatusCode)(Math.Floor(code / 100.0) * 100), out expiration)
? expiration
: TimeSpan.FromDays(1);
}
}