/// <summary> /// 获取缓存对象 /// </summary> /// <param name="key">缓存Key</param> /// <returns></returns> public T Get <T>(string key) where T : class { var value = redisConnection.GetDatabase().StringGet(key); if (value.HasValue) { //需要用的反序列化,将Redis存储的Byte[],进行反序列化 return(SerializeExtensions.Deserialize <T>(value)); } return(default);
/// <summary> /// 获取 /// </summary> /// <typeparam name="TEntity"></typeparam> /// <param name="key"></param> /// <returns></returns> public TEntity Get <TEntity>(string key) { var value = redisConnection.GetDatabase().StringGet(key); if (value.HasValue) { //需要用的反序列化,将Redis存储的Byte[],进行反序列化 return(SerializeExtensions.Deserialize <TEntity>(value)); } else { return(default(TEntity)); } }