Метод не найден с помощью StackExchange.RedisC#

Место общения программистов C#
Гость
Метод не найден с помощью StackExchange.Redis

Сообщение Гость »


Я пытаюсь реализовать кеширование Redis в нашей настройке sitecore, но у меня возникли проблемы с этим. Мы используем платформу dotnet 4.8 в контейнерной установке.
Я установил пакет StackExchange.Redis Nuget версии 2.7.27 и пытаюсь выполнить запись в кэш, используя

Код: Выделить всё

db.StringSet(applicationCacheKeyEnum.ToString(), objectJsonString, TimeSpan.MaxValue, true, When.Always);
. My code compiles, but at runtime I get the following error:

Код: Выделить всё

{
"Message": "An error has occurred.",
"ExceptionMessage": "Method not found: 'Boolean StackExchange.Redis.IDatabase.StringSet(StackExchange.Redis.RedisKey, StackExchange.Redis.RedisValue, System.Nullable`1, Boolean, StackExchange.Redis.When, StackExchange.Redis.CommandFlags)'.",
"ExceptionType": "System.MissingMethodException",
"StackTrace": "......"}
As far as I can see the signature of my method call matches Redis' StringSet() method, so I don't understand why this is happening. Below is the method in which I'm trying to set the cache value:

Код: Выделить всё

    public void AddToCache(ApplicationCacheKeyEnum applicationCacheKeyEnum, object theObject)
{
IDatabase db = _redisAccessor.Redis.GetDatabase(0);
string objectJsonString = JsonConvert.SerializeObject(theObject, Formatting.Indented);
db.StringSet(applicationCacheKeyEnum.ToString(), objectJsonString, TimeSpan.MaxValue, true, When.Always);
}
Can anyone help me understand, what causes the error?


Источник: https://stackoverflow.com/questions/781 ... ange-redis

Вернуться в «C#»