MemcachedFactory.cs 742 B

1234567891011121314151617181920212223242526272829
  1. using Enyim.Caching;
  2. namespace Lottomat.Cache.Memcached
  3. {
  4. public class MemcachedFactory
  5. {
  6. private static MemcachedClient _cacheClient = null;
  7. private static readonly object _lock = new object();
  8. /// <summary>
  9. /// 初始化Memcached对象
  10. /// </summary>
  11. /// <returns></returns>
  12. public static MemcachedClient GetMemcachedInstance()
  13. {
  14. if (_cacheClient == null)
  15. {
  16. lock (_lock)
  17. {
  18. if (_cacheClient == null)
  19. {
  20. _cacheClient = new MemcachedClient();
  21. }
  22. }
  23. }
  24. return _cacheClient;
  25. }
  26. }
  27. }