-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathICleverCacheStore.cs
More file actions
25 lines (19 loc) · 1.07 KB
/
ICleverCacheStore.cs
File metadata and controls
25 lines (19 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
namespace CleverCache;
/// <summary>
/// Abstraction over the underlying cache backend. Implement this interface to plug in a custom cache provider.
/// </summary>
public interface ICleverCacheStore
{
/// <summary>Attempts to retrieve a cached value by key.</summary>
bool TryGet<TItem>(object key, out TItem? value);
/// <summary>Asynchronously attempts to retrieve a cached value by key.</summary>
Task<(bool Hit, TItem? Value)> TryGetAsync<TItem>(object key, CancellationToken cancellationToken = default);
/// <summary>Stores a value in the cache.</summary>
void Set<TItem>(object key, TItem value, CleverCacheEntryOptions? options = null);
/// <summary>Asynchronously stores a value in the cache.</summary>
Task SetAsync<TItem>(object key, TItem value, CleverCacheEntryOptions? options = null, CancellationToken cancellationToken = default);
/// <summary>Removes a cached entry by key.</summary>
void Remove(object key);
/// <summary>Asynchronously removes a cached entry by key.</summary>
Task RemoveAsync(object key, CancellationToken cancellationToken = default);
}