geekbot/Geekbot.net/Lib/RedisClient.cs

27 lines
573 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
{
2017-04-14 21:36:01 +02:00
var redis = ConnectionMultiplexer.Connect("127.0.0.1:6379");
if (!redis.IsConnected)
2017-04-13 23:20:05 +02:00
{
2017-04-14 21:36:01 +02:00
Console.WriteLine("Could not Connect to the Server...");
2017-04-13 23:20:05 +02:00
}
2017-04-14 21:36:01 +02:00
Client = redis.GetDatabase();
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
}
}