Program.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using FreeRedis;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace WCS.DebugTool
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. RedisClient redis = null;
  14. while (true)
  15. {
  16. if (redis == null)
  17. {
  18. Console.WriteLine("请输入订阅关键字(逗号分隔):");
  19. redis = new RedisClient(Properties.Settings.Default.Redis);
  20. var key = Console.ReadLine();
  21. var arr = key.Split(',');
  22. redis.PSubscribe(arr, (channel, msg) =>
  23. {
  24. Console.Write(string.Format("对象:{0};", channel));
  25. Console.WriteLine(string.Format("消息:{0}", msg));
  26. });
  27. }
  28. else
  29. {
  30. if (Console.ReadKey().Key == ConsoleKey.Escape)
  31. {
  32. Console.Clear();
  33. redis.Dispose();
  34. redis = null;
  35. }
  36. }
  37. }
  38. }
  39. }
  40. }