async void buttonSendMessage_Click(object sender, RoutedEventArgs e) { try { using (var connection = new SocketConnection("127.0.0.1", 4525, Scheduler.Immediate)) { var publisher = connection.AsPublisher(); await publisher.PublishMessage("alert1", textBoxMessage.Text); //await publisher.PublishMessage("alert2", textBoxMessage.Text); } using (var connection = new SocketConnection("127.0.0.1", 4525, Scheduler.Immediate)) { var cacheClient = connection.AsCacheClient(); //await cacheClient.SetValue("alert1", textBoxMessage.Text); var result = await cacheClient.GetValues(new string[]{"alert1", "alert3"}); await cacheClient.Del("alert1"); var result2 = await cacheClient.GetValues(new string[] { "alert1", "alert3" }); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public async Task CanSetKeyAndGetValue() { var expected = "CanSetKeyAndGetValue"; using (var socketConnection = new SocketConnection(TestsSetup.Host, TestsSetup.Port, Scheduler.Immediate)) { var cacheClient = socketConnection.AsCacheClient(); await cacheClient.SetValue("test1", expected); var cacheValue = await cacheClient.GetValue("test1"); Assert.AreEqual(expected, cacheValue); } }
public async Task CanSetMultipleKeysAndGetValues() { var expected = "CanSetMultipleKeysAndGetValues"; var map = new Dictionary<string, string>(); map.Add("test2", expected); map.Add("test3", expected); using (var socketConnection = new SocketConnection(TestsSetup.Host, TestsSetup.Port, Scheduler.Immediate)) { var cacheClient = socketConnection.AsCacheClient(); await cacheClient.SetValues(map); var cacheValues = await cacheClient.GetValues(map.Keys.ToArray()); Assert.AreEqual(expected, cacheValues.Take(1).First()); Assert.AreEqual(expected, cacheValues.Skip(1).Take(1).First()); } }
public async Task CanSetKeysAndThenDeleteAll() { var expected = "CanSetKeysAndThenDeleteAll"; using (var socketConnection = new SocketConnection(TestsSetup.Host, TestsSetup.Port, Scheduler.Immediate)) { var cacheClient = socketConnection.AsCacheClient(); var map = new Dictionary<string, string>(); map.Add("test5", expected); map.Add("test6", expected); await cacheClient.SetValues(map); await cacheClient.Del(map.Keys.ToArray()); var cacheValues = await cacheClient.GetValues(map.Keys.ToArray()); Assert.IsTrue(cacheValues.All(x => x == null)); } }
public async Task CanSetKeyAndGetText() { var expected = Enumerable.Repeat("CanSetKeyAndGetText", 1024) .Aggregate( new StringBuilder(), (builder, value) => builder.Append(value), builder => builder.ToString()); using (var socketConnection = new SocketConnection(TestsSetup.Host, TestsSetup.Port, Scheduler.Immediate)) { var cacheClient = socketConnection.AsCacheClient(); await cacheClient.SetValue("test7", expected); var cacheValue = await cacheClient.GetValue("test7"); Assert.AreEqual(expected, cacheValue); } }