static void Main(string[] args) { //测试 Console.WriteLine("使用redis存放数据"); //RedisHelper.Add<string>("name", "hyt", DateTime.Now.AddDays(1)); //RedisHelper.Add<string>("Age", "28", DateTime.Now.AddDays(1)); Console.WriteLine(RedisHelper.Get <string>("name").ToString()); Console.WriteLine(RedisHelper.Get <string>("name").ToString()); Console.ReadKey(); }
static void Main(string[] args) { //启动Redis string redisPath = "Redis3\\redis-server.exe"; Process myprocess = new Process(); ProcessStartInfo startInfo = new ProcessStartInfo(redisPath, null); startInfo.CreateNoWindow = true; startInfo.RedirectStandardOutput = true; startInfo.UseShellExecute = false; myprocess.StartInfo = startInfo; bool flag = false; System.Threading.Mutex hMutex = new System.Threading.Mutex(true, "redis-server", out flag);//进程间的同步 bool b = hMutex.WaitOne(0, false); if (flag) { myprocess.Start(); } RedisHelper helper = new RedisHelper(); byte[] data = new byte[3] { 0x23, 0x34, 0x56 }; helper.Set("aaf", "nishizhu", 10); helper.Set("abc", data, 10); var value = helper.Get <string>("aaf"); byte[] bytes = helper.Get <byte[]>("abc"); Console.WriteLine(value); Console.WriteLine(BitConverter.ToString(bytes)); Console.ReadKey(); }
static void Main(string[] args) { RedisHelper redis = new RedisHelper(); string key = "csharp:user:1"; redis.Set(key, "祥哥哥"); var value = redis.Get <string>(key); Console.WriteLine("读取的" + key + "值:" + value); Console.ReadLine(); }
static void Main(string[] args) { RedisHelper rd = new RedisHelper(); TestClass tc = new TestClass(); tc.Id = 1; tc.Name = System.Guid.NewGuid().ToString(); tc.Pice = 3.141592679; tc.IsFlage = false; rd.Remove("i9"); var FindData = rd.Get <object>("441f2a63-2470-4809-967e-f24282b33ce1"); Console.WriteLine("写入成功"); //rd.Insert("i9", "我插进去了吗?"); Console.ReadKey(); }