Memory Cache

PHOTO EMBED

Tue Oct 04 2022 07:30:31 GMT+0000 (UTC)

Saved by @necamat #c#

using Microsoft.Extensions.Caching.Memory;

if (_memoryCache.TryGetValue("IME MEMORY CACHE", out var STA CUVAMO))
   {
       return STA CUVAMO;
   }
   else
   {
       STA CUVAMO = await _Provider.GetAsync();
     //VREME KOLIO CUVAMO TRECI PARAMETAR
       _memoryCache.Set("IME MEMORY CACHE", STA CUVAMO, TimeSpan.FromHours(8));
        return STA CUVAMO;
     }


// U PROGRAM CS
builder.Services.AddMemoryCache();
content_copyCOPY