Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void ConfigureServices(IServiceCollection services)
- {
- services.AddMvc();
- services.AddMemoryCache();
- }
- public interface IMemoryCache : IDisposable
- {
- bool TryGetValue(object key, out object value);
- ICacheEntry CreateEntry(object key);
- void Remove(object key);
- }
- public YourClassConstructor(IMemoryCache cache)
- {
- this.cache = cache;
- }
- cache.Set(“Key”, DataToCache);
- [HttpGet()]
- public string Get()
- {
- return cache.Get<TypeOfYourCachedData>(CacheKey);
- }
Add Comment
Please, Sign In to add comment