Using Redis to Go
Redis to Go is a hosted Redis database solution. After you
provision the Redis to Go add-on and re-deploy your application,
you can fetch the Redis url from the
<appSettings/>
section of your "Web.config"
file. The setting we inject is called REDISTOGO_URL
.
This is how you would read the string:
var redisUrl = ConfigurationManager.AppSettings.Get("REDISTOGO_URL");
Using ServiceStack.Redis (available from NuGet, make sure you have version 3.6.9 or newer):
var connectionUri = new Uri(redisUrl);
using (var redis = new RedisClient(connectionUri))
{
redis.Set("hello", "world");
var value = redis.Get<string>("hello");
}
Using Booksleeve (available from NuGet):
var connectionUri = new Uri(redisUrl);
var password = connectionUri.UserInfo.Split(':').LastOrDefault();
using (var conn = new RedisConnection(connectionUri.Host, port: connectionUri.Port, password: password))
{
conn.Open();
...
}