EnyimMemcachedContext.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // ***********************************************************************
  2. // Assembly : Infrastructure
  3. // Author : yubaolee
  4. // Created : 06-21-2016
  5. //
  6. // Last Modified By : yubaolee
  7. // Last Modified On : 06-21-2016
  8. // Contact :
  9. // File: EnyimMemcachedContext.cs
  10. // ***********************************************************************
  11. using System;
  12. using Enyim.Caching;
  13. using Enyim.Caching.Memcached;
  14. namespace Infrastructure.Cache
  15. {
  16. public sealed class EnyimMemcachedContext : ICacheContext
  17. {
  18. private static readonly MemcachedClient _memcachedClient = new MemcachedClient();
  19. public override T Get<T>(string key)
  20. {
  21. return _memcachedClient.Get<T>(key);
  22. }
  23. public override bool Set<T>(string key, T t, DateTime expire)
  24. {
  25. return _memcachedClient.Store(StoreMode.Set, key, t, expire);
  26. }
  27. public override bool Remove(string key)
  28. {
  29. return _memcachedClient.Remove(key);
  30. }
  31. }
  32. }