mirror of
https://github.com/Kareadita/Kavita.git
synced 2026-06-05 14:25:17 -04:00
Progress Overhaul + Profile Page and a LOT more! (#4262)
Co-authored-by: Amelia <77553571+Fesaa@users.noreply.github.com> Co-authored-by: Robbie Davis <robbie@therobbiedavis.com>
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Caching.Hybrid;
|
||||
|
||||
namespace API.Tests;
|
||||
|
||||
public class FakeHybridCacheWithTracking : FakeHybridCache
|
||||
{
|
||||
public IList<(string Key, object State, CancellationToken CancellationToken)> GetOrCreateAsyncCalls { get; } = [];
|
||||
public IList<(string Key, CancellationToken CancellationToken)> SetAsyncCalls { get; } = [];
|
||||
|
||||
public override async ValueTask<T> GetOrCreateAsync<TState, T>(
|
||||
string key,
|
||||
TState state,
|
||||
Func<TState, CancellationToken, ValueTask<T>> factory,
|
||||
HybridCacheEntryOptions? options = null,
|
||||
IEnumerable<string>? tags = null,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
GetOrCreateAsyncCalls.Add((key, state!, cancellationToken));
|
||||
return await base.GetOrCreateAsync(key, state, factory, options, tags, cancellationToken);
|
||||
}
|
||||
|
||||
public override ValueTask SetAsync<T>(
|
||||
string key,
|
||||
T value,
|
||||
HybridCacheEntryOptions? options = null,
|
||||
IEnumerable<string>? tags = null,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
SetAsyncCalls.Add((key, cancellationToken));
|
||||
return base.SetAsync(key, value, options, tags, cancellationToken);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user