Commit 028ab585 authored by Marc Gravell's avatar Marc Gravell

Use machine name as default client name; tests for RedisLabs SSL; remove "beta" copy from readme

parent b823aed4
...@@ -5,8 +5,6 @@ StackExchange.Redis is a high performance general purpose redis client for .NET ...@@ -5,8 +5,6 @@ StackExchange.Redis is a high performance general purpose redis client for .NET
and is the client developed-by (and used-by) [Stack Exchange](http://stackexchange.com/) for busy sites like [Stack Overflow](http://stackoverflow.com/). For the full reasons and is the client developed-by (and used-by) [Stack Exchange](http://stackexchange.com/) for busy sites like [Stack Overflow](http://stackoverflow.com/). For the full reasons
why this library was created (i.e. "What about BookSleeve?") [please see here](http://marcgravell.blogspot.com/2014/03/so-i-went-and-wrote-another-redis-client.html). why this library was created (i.e. "What about BookSleeve?") [please see here](http://marcgravell.blogspot.com/2014/03/so-i-went-and-wrote-another-redis-client.html).
Note: this release should be considered "beta": the API may be subject to minor changes.
Features Features
-- --
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
using System.Net; using System.Net;
using NUnit.Framework; using NUnit.Framework;
using System.Linq; using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Net.Security;
namespace StackExchange.Redis.Tests namespace StackExchange.Redis.Tests
{ {
...@@ -119,5 +121,55 @@ private static void TestConcurrent(IDatabase db, RedisKey key, int SyncLoop, int ...@@ -119,5 +121,55 @@ private static void TestConcurrent(IDatabase db, RedisKey key, int SyncLoop, int
(long)((SyncLoop * Threads) / time.TotalSeconds), (long)((SyncLoop * Threads) / time.TotalSeconds),
value); value);
} }
[Test]
public void RedisLabsSSL()
{
const string path = @"d:\RedisLabsSslHost.txt";
const string pfxPath = @"d:\RedisLabsUser.pfx";
if (!File.Exists(path)) Assert.Inconclusive();
string hostAndPort = File.ReadAllText(path);
int timeout = 5000;
if (Debugger.IsAttached) timeout *= 100;
var options = new ConfigurationOptions
{
EndPoints = { hostAndPort },
ConnectTimeout = timeout,
AllowAdmin = true,
CommandMap = CommandMap.Create(new HashSet<string> {
"subscribe", "unsubscribe", "cluster"
}, false)
};
if (!Directory.Exists(Me())) Directory.CreateDirectory(Me());
#if LOGOUTPUT
ConnectionMultiplexer.EchoPath = Me();
#endif
options.UseSsl = true;
options.CertificateSelection += delegate {
return new X509Certificate2(pfxPath, "pass");
};
RedisKey key = Me();
using(var conn = ConnectionMultiplexer.Connect(options))
{
var db = conn.GetDatabase();
db.KeyDelete(key);
string s = db.StringGet(key);
Assert.IsNull(s);
db.StringSet(key, "abc");
s = db.StringGet(key);
Assert.AreEqual("abc", s);
var latency = db.Ping();
Console.WriteLine("RedisLabs latency: {0:###,##0.##}ms", latency.TotalMilliseconds);
using (var file = File.Create("RedisLabs.zip"))
{
conn.ExportConfiguration(file);
}
}
}
} }
} }
...@@ -14,7 +14,7 @@ partial class ConnectionMultiplexer ...@@ -14,7 +14,7 @@ partial class ConnectionMultiplexer
partial void OnCreateReaderWriter(ConfigurationOptions configuration) partial void OnCreateReaderWriter(ConfigurationOptions configuration)
{ {
this.ownsSocketManager = configuration.SocketManager == null; this.ownsSocketManager = configuration.SocketManager == null;
this.socketManager = configuration.SocketManager ?? new SocketManager(configuration.ClientName); this.socketManager = configuration.SocketManager ?? new SocketManager(ClientName);
} }
partial void OnCloseReaderWriter() partial void OnCloseReaderWriter()
......
...@@ -69,9 +69,9 @@ public ServerCounters GetCounters() ...@@ -69,9 +69,9 @@ public ServerCounters GetCounters()
} }
/// <summary> /// <summary>
/// Gets or sets a client-name that will be used on all new connections /// Gets the client-name that will be used on all new connections
/// </summary> /// </summary>
public string ClientName { get { return configuration.ClientName; } } public string ClientName { get { return configuration.ClientName ?? Environment.MachineName; } }
/// <summary> /// <summary>
/// Gets the configuration of the connection /// Gets the configuration of the connection
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Diagnostics; using System.Diagnostics;
using System.Text.RegularExpressions;
namespace StackExchange.Redis namespace StackExchange.Redis
{ {
#if DEBUG #if DEBUG
......
namespace StackExchange.Redis using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
namespace StackExchange.Redis
{ {
#if LOGOUTPUT #if LOGOUTPUT
sealed class LoggingTextStream : Stream sealed class LoggingTextStream : Stream
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment