geekbot/Geekbot.net/Lib/IClients/RedisClient.cs

31 lines
641 B
C#
Raw Normal View History

2017-04-13 23:20:05 +02:00
using System;
using StackExchange.Redis;
namespace Geekbot.net.Lib
{
2017-04-14 21:36:01 +02:00
public interface IRedisClient
2017-04-13 23:20:05 +02:00
{
2017-04-14 21:36:01 +02:00
IDatabase Client { get; set; }
}
public sealed class RedisClient : IRedisClient
{
public RedisClient()
2017-04-13 23:20:05 +02:00
{
try
{
var redis = ConnectionMultiplexer.Connect("127.0.0.1:6379");
2017-04-18 14:08:56 +02:00
Client = redis.GetDatabase(6);
}
catch (Exception)
2017-04-13 23:20:05 +02:00
{
Console.WriteLine("Start Redis pls...");
Environment.Exit(1);
2017-04-13 23:20:05 +02:00
}
}
2017-04-14 21:36:01 +02:00
public IDatabase Client { get; set; }
2017-04-13 23:20:05 +02:00
}
}