static void Main(string[] args) { ConsoleHelper.Title = "SAEA.RedisSocketTest"; ConsoleHelper.WriteLine("输入连接字符串连接RedisServer,格式为\r\nserver=127.0.0.1:6379;passwords=yswenli"); var cnnStr = ConsoleHelper.ReadLine(); if (string.IsNullOrEmpty(cnnStr)) { cnnStr = "server=127.0.0.1:6379;passwords=yswenli"; } RedisClient redisClient = new RedisClient(cnnStr, false); redisClient.Connect(); var rk = redisClient.GetDataBase().RandomKey(); var crk = redisClient.Console("RandomKey"); var type = redisClient.Type("FUND_GROUP_TG_5c8abef4c30c6b9a"); ConsoleHelper.WriteLine(type); var type1 = redisClient.Type("FUND_GROUP_TG_176d0049714c618a"); ConsoleHelper.WriteLine(type1); var type2 = redisClient.Type("POINT_GROUP_PG_ad011ad469744a6bbc79981c1d0811d6"); ConsoleHelper.WriteLine(type2); var type3 = redisClient.Type("FUND_GROUP_TG_48fb4e9e8d6dda15"); ConsoleHelper.WriteLine(type3); var type4 = redisClient.Type("POINT_GROUP_PG_8136d029050740acab7a3d24a6e88663"); ConsoleHelper.WriteLine(type4); ConsoleHelper.ReadLine(); KeysTest(redisClient); var db = redisClient.GetDataBase(0); StringTest(db); ConsoleHelper.ReadLine(); HashTest(db); ListTest(db); SetTest(db); GeoTest(db); ConsoleHelper.ReadLine(); }
static void Main(string[] args) { ConsoleHelper.Title = "SAEA.RedisSocketTest"; ConsoleHelper.WriteLine("输入连接字符串连接RedisServer,格式为\r\nserver=127.0.0.1:6379;passwords=yswenli"); var cnnStr = ConsoleHelper.ReadLine(); if (string.IsNullOrEmpty(cnnStr)) { //cnnStr = "server=127.0.0.1:6379;passwords=yswenli"; cnnStr = "server=127.0.0.1:6379;passwords=yswenli"; } RedisClient redisClient = new RedisClient(cnnStr, false); redisClient.Connect(); redisClient.Select(1); var list = redisClient.GetDataBase().LRang("list1", 0, 10); //redisClient.GetDataBase().HSet("test", "", "2151"); //var isCluster = redisClient.IsCluster; //var list = redisClient.ClusterNodes; var keys = redisClient.GetDataBase().Keys(); var scan = redisClient.GetDataBase().Scan(); var hscan = redisClient.GetDataBase().HScan("haa22", 0); var sscan = redisClient.GetDataBase().SScan("aaa", 0); redisClient.GetDataBase().ZAdd("zaaa", "!#@%$^&*\r\n()^^%%&%@FSDH\r\n某月霜\r\n/.';lakdsfakdsf", 110); var zscan = redisClient.GetDataBase().ZScan("zaaa", 0); //var r = redisClient.GetDataBase().Rename("aaa", "aaa"); //var l = redisClient.GetDataBase().LRang("testlist"); //var z = redisClient.GetDataBase().ZRang("zaaa"); var h = redisClient.GetDataBase().HGetAll("haa22"); var t1 = redisClient.GetDataBase().Ttl("zaaa"); var t2 = redisClient.GetDataBase().Ttl("haa22"); var t3 = redisClient.GetDataBase().Pttl("key0"); var t4 = redisClient.GetDataBase().Pttl("akey0"); //var m = redisClient.ClusterInfo; //var n = redisClient.ClusterNodes; //var k = redisClient.KeySlot("aaa"); //var g = redisClient.GetKeysInSlot(0); //redisClient.GetDataBase().SRemove("abcd", "12345"); var info = redisClient.Info(); var serverInfo = redisClient.ServerInfo; var r = redisClient.Console("scan 0"); if (info.Contains("NOAUTH Authentication required.")) { while (true) { ConsoleHelper.WriteLine("请输入redis连接密码"); var auth = ConsoleHelper.ReadLine(); if (string.IsNullOrEmpty(auth)) { auth = "yswenli"; } var a = redisClient.Auth(auth); if (a.Contains("OK")) { break; } else { ConsoleHelper.WriteLine(a); } } } //redisClient.SlaveOf(); var pong = redisClient.Ping(); //redisClient.Select(1); PerformanceTest(redisClient); ConsoleHelper.WriteLine(redisClient.Type("key0")); ConsoleHelper.WriteLine("dbSize:{0}", redisClient.DBSize().ToString()); RedisOperationTest(redisClient, true); ConsoleHelper.ReadLine(); }
static void Main(string[] args) { ConsoleHelper.Title = "SAEA.RedisSocketTest"; ConsoleHelper.WriteLine("输入连接字符串连接RedisServer,格式为\r\nserver=127.0.0.1:6379;passwords=yswenli"); var cnnStr = ConsoleHelper.ReadLine(); if (string.IsNullOrEmpty(cnnStr)) { cnnStr = "server=127.0.0.1:6379;passwords=yswenli"; } RedisClient redisClient = new RedisClient(cnnStr, false); redisClient.Connect(); var info = redisClient.Info(); #region 异步测试 redisClient.GetDataBase().HSetAsync(TimeSpan.FromSeconds(5), "hid", "key", "val"); var r = redisClient.GetDataBase().HGetAsync(TimeSpan.FromSeconds(5), "hid", "key").Result; var rr = redisClient.GetDataBase().HDelAsync(TimeSpan.FromSeconds(5), "hid", "key").Result; //var batch = redisClient.GetDataBase().CreatedBatch(); //for (int i = 0; i < 100000; i++) //{ // batch.ZAddAsync("yswenliG", i.ToString(), i); //} //_ = batch.Execute().ToList(); #endregion #region scan var sresult1 = redisClient.GetDataBase().Scan(); var sresult2 = redisClient.GetDataBase().Scan(0, "*", -1); #endregion StringPerformanceTest(redisClient); BatchTest(redisClient); var rk = redisClient.GetDataBase().RandomKey(); var crk = redisClient.Console("RandomKey"); ConsoleHelper.ReadLine(); KeysTest(redisClient); var db = redisClient.GetDataBase(0); StringTest(db); ConsoleHelper.ReadLine(); HashTest(db); ListTest(db); SetTest(db); GeoTest(db); ConsoleHelper.ReadLine(); }
static void Main(string[] args) { ConsoleHelper.Title = "SAEA.RedisSocketTest"; #region KeepOnTest //KeepOnTest.Test(); #endregion ConsoleHelper.WriteLine("输入连接字符串连接RedisServer,格式为\r\nserver=127.0.0.1:6379;passwords=yswenli"); var cnnStr = ConsoleHelper.ReadLine(); if (string.IsNullOrEmpty(cnnStr)) { cnnStr = "server=127.0.0.1:6379;passwords=yswenli"; } RedisClient redisClient = new RedisClient(cnnStr, false); redisClient.Connect(); var info = redisClient.Info(); var response = redisClient.Console("role"); var bh = redisClient.GetDataBase().HGetAll("Task"); var zr = redisClient.GetDataBase().ZScan("ArbitrationRecords"); #region scan var sresult1 = redisClient.GetDataBase().Scan(); var sresult2 = redisClient.GetDataBase().Scan(0, "*", -1); #endregion for (int i = 0; i < 16; i++) { redisClient.Select(i); } redisClient.Select(0); StringPerformanceTest(redisClient); //BatchTest(redisClient); var rk = redisClient.GetDataBase().RandomKey(); var crk = redisClient.Console("RandomKey"); ConsoleHelper.ReadLine(); keysTest(redisClient); var db = redisClient.GetDataBase(0); StringTest(db); ConsoleHelper.ReadLine(); HashTest(db); ListTest(db); SetTest(db); GeoTest(db); #region redis stream test new RedisStreamTest(redisClient).Test(); #endregion ConsoleHelper.ReadLine(); }