You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MemoryOutputCache.cs 780B

1234567891011121314151617181920212223242526272829303132333435
  1. using System.Runtime.Caching;
  2. namespace iiie.CacheControl.Business.OutputCache
  3. {
  4. public class MemoryOutputCache : IOutputCache
  5. {
  6. private static readonly MemoryCache Cache = MemoryCache.Default;
  7. public override object Get(string key)
  8. {
  9. return Cache.Get(key);
  10. }
  11. public override void Remove(string key)
  12. {
  13. lock (Cache)
  14. {
  15. Cache.Remove(key);
  16. }
  17. }
  18. public override bool Contains(string key)
  19. {
  20. return Cache.Contains(key);
  21. }
  22. public override void Add(string key, object o)
  23. {
  24. lock (Cache)
  25. {
  26. Cache.Add(key, o, new CacheItemPolicy());
  27. }
  28. }
  29. }
  30. }