Guest User

Untitled

a guest
Jan 20th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. public void ConfigureServices(IServiceCollection services)
  2. {
  3. services.AddMvc();
  4. services.AddMemoryCache();
  5. }
  6.  
  7. public interface IMemoryCache : IDisposable
  8. {
  9. bool TryGetValue(object key, out object value);
  10. ICacheEntry CreateEntry(object key);
  11. void Remove(object key);
  12. }
  13.  
  14. public YourClassConstructor(IMemoryCache cache)
  15. {
  16. this.cache = cache;
  17. }
  18.  
  19. cache.Set(“Key”, DataToCache);
  20.  
  21. [HttpGet()]
  22. public string Get()
  23. {
  24. return cache.Get<TypeOfYourCachedData>(CacheKey);
  25. }
Add Comment
Please, Sign In to add comment