CacheFactory.cs 810 B

123456789101112131415161718192021222324252627282930313233343536
  1. using KC.Cache.Redis;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using Common;
  8. namespace KC.Cache
  9. {
  10. public class CacheFactory
  11. {
  12. /// <summary>
  13. /// 获取缓存对象
  14. /// </summary>
  15. /// <returns></returns>
  16. public static ICache GetCache(CacheType cacheType = CacheType.WebCacne)
  17. {
  18. switch (cacheType)
  19. {
  20. case CacheType.WebCacne:
  21. return new KC.Cache.WebCache.WebCache();
  22. case CacheType.RedisCache:
  23. return new RedisCache();
  24. };
  25. return RedisCache.GetRedisCache();
  26. }
  27. }
  28. public enum CacheType
  29. {
  30. WebCacne = 1,
  31. RedisCache = 2
  32. }
  33. }