Overriding Existing Methods
How to Override?
1. Create a New Service to Override Existing Method
public class OverridedRENInMemoryCacheService(IMemoryCache memoryCache)
: RENInMemoryCacheService(memoryCache)
{
public override async Task<T> GetAsync<T>(string cacheKey,
CancellationToken cancellationToken = default)
{
Console.WriteLine($"OverridedRENInMemoryCacheService GetAsync called");
// You can add custom logic here before calling the base method
return await base.GetAsync<T>(cacheKey, cancellationToken);
}
}2. Register Your Custom Implementation
3. Use Custom Service In Action
Last updated