using CoviDok.BLL.Sessions; using StackExchange.Redis; using System; using System.Collections.Generic; using System.Text; namespace CoviDok.Data.SessionProviders { class RedisProvider : ISessionProvider { // The Multiplexer is thread safe, connections are not private readonly ConnectionMultiplexer muxer; public static string Host { get; set; } public RedisProvider() { muxer = ConnectionMultiplexer.Connect(Host); } public void Del(string key) { IDatabase conn = muxer.GetDatabase(); conn.KeyDelete(key); } public string Get(string key) { IDatabase conn = muxer.GetDatabase(); return conn.StringGet(key); } public void Set(string key, string value) { IDatabase conn = muxer.GetDatabase(); conn.StringSet(key, value); } } }