-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(GH-613) Re-factor the in-memory caching provider
- Loading branch information
1 parent
75665e0
commit 4c2d6fc
Showing
3 changed files
with
136 additions
and
181 deletions.
There are no files selected for viewing
136 changes: 0 additions & 136 deletions
136
src/DotNetToolkit.Repository.Caching.InMemory/InMemoryCache.cs
This file was deleted.
Oops, something went wrong.
52 changes: 52 additions & 0 deletions
52
src/DotNetToolkit.Repository.Caching.InMemory/InMemoryCacheOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
namespace DotNetToolkit.Repository.Caching.InMemory | ||
{ | ||
using DotNetToolkit.Repository.Utility; | ||
using JetBrains.Annotations; | ||
using Microsoft.Extensions.Internal; | ||
using System; | ||
|
||
/// <summary> | ||
/// The options to be used by the in-memory caching provider. | ||
/// </summary> | ||
public class InMemoryCacheOptions | ||
{ | ||
internal ISystemClock Clock { get; set; } | ||
internal TimeSpan? ExpirationScanFrequency { get; set; } | ||
internal TimeSpan? Expiry { get; set; } | ||
|
||
internal InMemoryCacheOptions() { } | ||
|
||
/// <summary> | ||
/// Adds the giving system clock vaue to the options. | ||
/// </summary> | ||
/// <param name="clock">The system clock to be added.</param> | ||
public InMemoryCacheOptions WithClock([NotNull] ISystemClock clock) | ||
{ | ||
Clock = Guard.NotNull(clock, nameof(clock)); | ||
|
||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// Adds the giving system clock vaue to the options. | ||
/// </summary> | ||
/// <param name="expirationScanFrequency">The minimum length of time between successive scans for expired items to be added.</param> | ||
public InMemoryCacheOptions WithExpirationScanFrequency([NotNull] TimeSpan expirationScanFrequency) | ||
{ | ||
ExpirationScanFrequency = Guard.NotNull(expirationScanFrequency, nameof(expirationScanFrequency)); | ||
|
||
return this; | ||
} | ||
|
||
/// <summary> | ||
/// Adds the giving caching expiration time to the options. | ||
/// </summary> | ||
/// <param name="expiry">The caching expiration time to be added.</param> | ||
public InMemoryCacheOptions WithExpiry([NotNull] TimeSpan expiry) | ||
{ | ||
Expiry = Guard.NotNull(expiry, nameof(expiry)); | ||
|
||
return this; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters