MemCachedConfig.cs 996 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using CB.Common;
  5. namespace CB.Cache.MemCached
  6. {
  7. /// <summary>
  8. /// 设置或载入MemCached的配置
  9. ///
  10. /// </summary>
  11. public class MemCachedConfig
  12. {
  13. private static object _lockHelper = new object();
  14. private static MemCachedConfigInfo config = null;
  15. public static void LoadConfig(string configfilepath)
  16. {
  17. if (config == null)
  18. {
  19. lock (_lockHelper)
  20. {
  21. if (config == null)
  22. {
  23. config = JSONUtil.ParseFormByJson<MemCachedConfigInfo>(Utils.ReadFile(configfilepath));
  24. }
  25. }
  26. }
  27. }
  28. /// <summary>
  29. /// 获取配置
  30. /// </summary>
  31. /// <param name="anConfig"></param>
  32. public static MemCachedConfigInfo GetConfig()
  33. {
  34. return config;
  35. }
  36. }
  37. }