Assume i have the following interface:
public interface IApiOutputCache
{
Task RemoveStartsWithAsync(string key);
Task<T> Get<T>(string key) where T : class;
Task RemoveAsync(string key);
Task<bool> ContainsAsync(string key);
Task Add(string key, object o, DateTimeOffset expiration, params string[] dependsOnKeys);
Task<IEnumerable<string>> GetAllKeys();
}
I can implement different cache providers. I implemented it twice for two different caches:
a) azure redis b) memory cache
For azure redis this works absolutely fine since StackExchange.Redis offers all the async methods for me so i can stay completely async.
Now i implement another one for the memory cache which does not offer async api for me.
Now what is the best pratice to implement this interface?
Implement it as is but just do everything sync? Warp the internal calls to a Task.Run
(not a good idea for fast mem cache calls i think).