40 lines
758 B
C#
40 lines
758 B
C#
using StackExchange.Redis;
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace HuanMeng.DotNetCore.Redis;
|
|
|
|
/// <summary>
|
|
/// redis帮助类
|
|
/// </summary>
|
|
public class RedisHelper
|
|
{
|
|
public RedisHelper(IConnectionMultiplexer redis)
|
|
{
|
|
_redis = redis;
|
|
}
|
|
|
|
private readonly IConnectionMultiplexer _redis;
|
|
|
|
public async Task<string> GetValue(string key)
|
|
{
|
|
var db = _redis.GetDatabase();
|
|
return await db.StringGetAsync(key);
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="redisConnection"></param>
|
|
/// <returns></returns>
|
|
public IDatabase GetRedis()
|
|
{
|
|
return _redis.GetDatabase();
|
|
}
|
|
|
|
|
|
}
|