Ich verwende .NET Core 2.0 mit Microsoft.Extensions.Caching.Redis 2.0. Warum ist IDistributedCache.SetStringAsync nicht wirklich als async markiert und daher nicht abzusehen?SetStringAsync in IDistributedCache kann nicht erwartet werden
var services = new ServiceCollection();
services.AddDistributedRedisCache(options =>
{
options.Configuration = "127.0.0.1";
options.InstanceName = "master";
});
var provider = services.BuildServiceProvider();
var cache = provider.GetService<IDistributedCache>();
// Does not compile
await cache.SetStringAsync("mykey", "myvalue");
Es sieht aus wie Schnittstelle 'IDistributedCache' hat diese Methode nicht: https://github.com/aspnet/Caching/blob/dev/src/Microsoft.Extensions.Caching.Abstractions/IDistributedC ache.cs –
... aber Sie können es mit dieser Erweiterung tun https://github.com/aspnet/Caching/blob/dev/src/Microsoft.Extensions.Caching.Abstractions/DistributedCacheExtensions.cs ... Was Compiler tut Fehler sagt? Ist die Methode, die auf async wartet, markiert? –
Rufen Sie SetStringAsync von einer asynchronen Methode auf? –