RoadFlow2.1 临时演示

Cache.cs 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace RoadFlow.Cache.IO
  6. {
  7. public class Opation
  8. {
  9. private static Interface.ICache myCache = Factory.Cache.CreateInstance();
  10. /// <summary>
  11. /// 插入缓存
  12. /// </summary>
  13. /// <param name="key"></param>
  14. /// <param name="obj"></param>
  15. /// <returns></returns>
  16. public static bool Insert(string key, object obj)
  17. {
  18. return myCache.Insert(key, obj);
  19. }
  20. /// <summary>
  21. /// 设置缓存
  22. /// </summary>
  23. /// <param name="key"></param>
  24. /// <param name="obj"></param>
  25. /// <returns></returns>
  26. public static bool Set(string key, object obj)
  27. {
  28. return Insert(key, obj);
  29. }
  30. /// <summary>
  31. /// 插入缓存
  32. /// </summary>
  33. /// <param name="key"></param>
  34. /// <param name="obj"></param>
  35. /// <returns></returns>
  36. public static bool Insert(string key, object obj, DateTime expiry)
  37. {
  38. return myCache.Insert(key, obj, expiry);
  39. }
  40. /// <summary>
  41. /// 插入缓存
  42. /// </summary>
  43. /// <param name="key"></param>
  44. /// <param name="obj"></param>
  45. /// <returns></returns>
  46. public static bool Set(string key, object obj, DateTime expiry)
  47. {
  48. return Insert(key, obj, expiry);
  49. }
  50. /// <summary>
  51. /// 获取缓存
  52. /// </summary>
  53. /// <param name="key"></param>
  54. /// <returns></returns>
  55. public static object Get(string key)
  56. {
  57. return myCache.Get(key);
  58. }
  59. /// <summary>
  60. /// 移出缓存
  61. /// </summary>
  62. /// <param name="key"></param>
  63. public static bool Remove(string key)
  64. {
  65. return myCache.Remove(key);
  66. }
  67. /// <summary>
  68. /// 清空所有缓存
  69. /// </summary>
  70. /// <returns></returns>
  71. public static void RemoveAll()
  72. {
  73. myCache.RemoveAll();
  74. }
  75. }
  76. }