//
namespace SafeCampus.Cache;
///
///
/// Redis缓存
///
public partial class RedisCacheService : ISimpleCacheService
{
private readonly ISimpleRedis _simpleRedis;
public RedisCacheService(ISimpleRedis simpleRedis)
{
_simpleRedis = simpleRedis;
}
#region 普通操作
///
public T Get(string key)
{
return _simpleRedis.Get(key);
}
///
public int Remove(params string[] keys)
{
return _simpleRedis.GetFullRedis().Remove(keys);
}
///
public bool Set(string key, T value, int expire = -1)
{
return _simpleRedis.Set(key, value, expire);
}
///
public bool Set(string key, T value, TimeSpan expire)
{
return _simpleRedis.Set(key, value, expire);
}
///
public bool SetExpire(string key, TimeSpan expire)
{
return _simpleRedis.GetFullRedis().SetExpire(key, expire);
}
///
public TimeSpan GetExpire(string key)
{
return _simpleRedis.GetFullRedis().GetExpire(key);
}
///
public bool ContainsKey(string key)
{
return _simpleRedis.ContainsKey(key);
}
///
public void Clear()
{
_simpleRedis.Clear();
}
///
public void DelByPattern(string pattern)
{
_simpleRedis.DelByPattern(pattern);
}
#endregion 普通操作
#region 集合操作
///
public IDictionary GetAll(IEnumerable keys)
{
return _simpleRedis.GetFullRedis().GetAll(keys);
}
///
public void SetAll(IDictionary values, int expire = -1)
{
_simpleRedis.GetFullRedis().SetAll(values, expire);
}
///
public IDictionary GetDictionary(string key)
{
return _simpleRedis.GetFullRedis().GetDictionary(key);
}
///
public IProducerConsumer GetQueue(string key)
{
return _simpleRedis.GetFullRedis().GetQueue(key);
}
///
public IProducerConsumer GetStack(string key)
{
return _simpleRedis.GetFullRedis().GetStack(key);
}
///
public ICollection GetSet(string key)
{
return _simpleRedis.GetFullRedis().GetSet(key);
}
#endregion 集合操作
#region 高级操作
///
public bool Add(string key, T value, int expire = -1)
{
return _simpleRedis.GetFullRedis().Add(key, value, expire);
}
///
public IList GetList(string key)
{
return _simpleRedis.GetFullRedis().GetList(key);
}
///
public T Replace(string key, T value)
{
return _simpleRedis.GetFullRedis().Replace(key, value);
}
///
public bool TryGetValue(string key, out T value)
{
return _simpleRedis.GetFullRedis().TryGetValue(key, out value);
}
///
public long Decrement(string key, long value)
{
return _simpleRedis.GetFullRedis().Decrement(key, value);
}
///
public double Decrement(string key, double value)
{
return _simpleRedis.GetFullRedis().Decrement(key, value);
}
///
public long Increment(string key, long value)
{
return _simpleRedis.GetFullRedis().Increment(key, value);
}
///
public double Increment(string key, double value)
{
return _simpleRedis.GetFullRedis().Increment(key, value);
}
#endregion 高级操作
#region 事务
///
public int Commit()
{
return _simpleRedis.GetFullRedis().Commit();
}
///
public IDisposable AcquireLock(string key, int msTimeout)
{
return _simpleRedis.GetFullRedis().AcquireLock(key, msTimeout);
}
///
public IDisposable AcquireLock(string key, int msTimeout, int msExpire,
bool throwOnFailure)
{
return _simpleRedis.GetFullRedis().AcquireLock(key, msTimeout, msExpire, throwOnFailure);
}
#endregion 事务
}