Skip to content

Commit 2eeec46

Browse files
authored
Merge pull request #18 from Leefrost/docs
Internal documentations
2 parents dcfd183 + a84beca commit 2eeec46

File tree

6 files changed

+93
-2
lines changed

6 files changed

+93
-2
lines changed

src/HttpClient.Cache/ICacheEntry.cs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,44 @@
11
namespace HttpClient.Cache;
22

3+
/// <summary>
4+
/// Cache value holder
5+
/// </summary>
36
public interface ICacheEntry: IDisposable
47
{
8+
/// <summary>
9+
/// Cache value
10+
/// </summary>
511
object Value { get; set; }
612

13+
/// <summary>
14+
/// Cache entry priority
15+
/// </summary>
16+
CacheEntryPriority Priority { get; set; }
17+
18+
/// <summary>
19+
/// Entry absolute expiration. The entry will be expired after a set amount of time
20+
/// </summary>
721
DateTimeOffset? AbsoluteExpiration { get; set; }
822

23+
/// <summary>
24+
/// Entry absolute expiration relative to created time. The entry will be expired a set amount of time from now
25+
/// </summary>
926
TimeSpan? AbsoluteExpirationRelativeToNow { get; set; }
1027

28+
/// <summary>
29+
/// Entry sliding expiration. Entry will be expired if it hasn't been accessed in a set amount of time.
30+
/// </summary>
1131
TimeSpan? SlidingExpiration { get; set; }
1232

33+
/// <summary>
34+
/// Collection of <see cref="IChangeToken"/> tokens.
35+
/// Any lifecycle changes will appear here
36+
/// </summary>
1337
IList<IChangeToken> ExpirationTokens { get; }
1438

39+
/// <summary>
40+
/// Collection of <see cref="PostEvictionCallbackRegistration"/> callbacks.
41+
/// Will be executed on entry eviction
42+
/// </summary>
1543
IList<PostEvictionCallbackRegistration> PostEvictionCallbacks { get; }
16-
17-
CacheEntryPriority Priority { get; set; }
1844
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
namespace HttpClient.Cache;
22

3+
/// <summary>
4+
/// Cache keys generator
5+
/// </summary>
36
public interface ICacheKeysProvider
47
{
8+
/// <summary>
9+
/// Generate a cache key for <see cref="HttpRequestMessage"/> http request
10+
/// </summary>
11+
/// <param name="request">Http request</param>
12+
/// <returns>Cache key</returns>
513
string GetKey(HttpRequestMessage request);
614
}

src/HttpClient.Cache/IChangeToken.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
11
namespace HttpClient.Cache;
22

3+
/// <summary>
4+
/// Defines the mechanism for checking the changes over the cache entry
5+
/// </summary>
36
public interface IChangeToken
47
{
8+
/// <summary>
9+
/// Cache entry is changed
10+
/// </summary>
511
bool HasChanged { get; }
612

13+
/// <summary>
14+
/// Call the callback on change
15+
/// </summary>
716
bool ActiveChangeCallbacks { get; }
817

18+
/// <summary>
19+
/// Register a callback to call on change
20+
/// </summary>
21+
/// <param name="callback">Callback to call</param>
22+
/// <param name="state">Current state</param>
23+
/// <returns><see cref="IDisposable"/> callback handler</returns>
924
IDisposable RegisterChangeCallback(Action<object> callback, object state);
1025
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
namespace HttpClient.Cache.InMemory.Clock;
22

3+
/// <summary>
4+
/// Defines cache clock
5+
/// </summary>
36
public interface ISystemClock
47
{
8+
/// <summary>
9+
/// Current time
10+
/// </summary>
511
DateTimeOffset UtcNow { get; }
612
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,33 @@
11
namespace HttpClient.Cache.InMemory;
22

3+
/// <summary>
4+
/// Describes the API for InMemory cache
5+
/// </summary>
36
public interface IMemoryCache: IDisposable
47
{
8+
/// <summary>
9+
/// Getting the cache value by key
10+
/// </summary>
11+
/// <param name="key">Entry key</param>
12+
/// <param name="value">Cache value</param>
13+
/// <returns>True if entry exist and returned, otherwise - false</returns>
514
bool TryGetValue(object key, out object? value);
615

16+
/// <summary>
17+
/// Create empty cache entry
18+
/// </summary>
19+
/// <param name="key">Entry key</param>
20+
/// <returns><see cref="ICacheEntry"/> cache entry</returns>
721
ICacheEntry CreateEntry(object key);
822

23+
/// <summary>
24+
/// Remove entry by key
25+
/// </summary>
26+
/// <param name="key">Entry key</param>
927
void Remove(object key);
1028

29+
/// <summary>
30+
/// Clean the cache
31+
/// </summary>
1132
void Clear();
1233
}

src/HttpClient.Cache/Stats/ICacheStatsProvider.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,26 @@
22

33
namespace HttpClient.Cache.Stats;
44

5+
/// <summary>
6+
/// Defines a mechanism to report cache hit/miss and generate on this info a cache report
7+
/// </summary>
58
public interface ICacheStatsProvider
69
{
10+
/// <summary>
11+
/// Mark a cache hit
12+
/// </summary>
13+
/// <param name="code">Target code</param>
714
void ReportHit(HttpStatusCode code);
815

16+
/// <summary>
17+
/// Mark a cache miss
18+
/// </summary>
19+
/// <param name="code">Target code</param>
920
void ReportMiss(HttpStatusCode code);
1021

22+
/// <summary>
23+
/// Gets stored cache report
24+
/// </summary>
25+
/// <returns><see cref="CacheStatsReport"/> report</returns>
1126
CacheStatsReport GetReport();
1227
}

0 commit comments

Comments
 (0)