AbpMemoryCacheManager.cs 1014 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. using Abp.Dependency;
  2. using Abp.Runtime.Caching.Configuration;
  3. using Castle.Core.Logging;
  4. namespace Abp.Runtime.Caching.Memory
  5. {
  6. /// <summary>
  7. /// Implements <see cref="ICacheManager"/> to work with MemoryCache.
  8. /// </summary>
  9. public class AbpMemoryCacheManager : CacheManagerBase
  10. {
  11. public ILogger Logger { get; set; }
  12. /// <summary>
  13. /// Constructor.
  14. /// </summary>
  15. public AbpMemoryCacheManager(IIocManager iocManager, ICachingConfiguration configuration)
  16. : base(iocManager, configuration)
  17. {
  18. Logger = NullLogger.Instance;
  19. }
  20. protected override ICache CreateCacheImplementation(string name)
  21. {
  22. return new AbpMemoryCache(name)
  23. {
  24. Logger = Logger
  25. };
  26. }
  27. protected override void DisposeCaches()
  28. {
  29. foreach (var cache in Caches.Values)
  30. {
  31. cache.Dispose();
  32. }
  33. }
  34. }
  35. }