0

I want to set cache to redis but I get an reror:

System.NullReferenceException: Object reference not set to an instance of an object.

My code

DistributedCacheEntryOptions options = new DistributedCacheEntryOptions();
options.AbsoluteExpiration = DateTime.Now.AddMinutes(1);
options.AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(1);
options.SlidingExpiration = TimeSpan.FromSeconds(30);

_distributedCache.SetString("zaman", DateTime.Now.ToString(), options);

enter image description here

enter image description here

Even though I filled in all the relevant fields, the code throws a System.NullReferenceException

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

0 Answers0