|
|
@ -89,6 +89,19 @@ public class RedisHelper : IDisposable
|
|
|
|
return db.StringGet(key);
|
|
|
|
return db.StringGet(key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 先进先出队列
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="topic"></param>
|
|
|
|
|
|
|
|
/// <param name="value"></param>
|
|
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
public void PublishAsync(string topic, string value)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ISubscriber sub = GetConnect().GetSubscriber();
|
|
|
|
|
|
|
|
sub.PublishAsync(topic, value);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 获取Redis中的值(异步版本)
|
|
|
|
/// 获取Redis中的值(异步版本)
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
@ -107,7 +120,7 @@ public class RedisHelper : IDisposable
|
|
|
|
/// <param name="value">值</param>
|
|
|
|
/// <param name="value">值</param>
|
|
|
|
/// <param name="expiry">值</param>
|
|
|
|
/// <param name="expiry">值</param>
|
|
|
|
/// <returns>操作是否成功</returns>
|
|
|
|
/// <returns>操作是否成功</returns>
|
|
|
|
public bool SetKeyValueStr(string key, string value, TimeSpan? expiry = default(TimeSpan?))
|
|
|
|
public bool SetKeyValueStr(string key, string value, TimeSpan? expiry = default(TimeSpan?))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var db = GetConnect().GetDatabase(_defaultDB);
|
|
|
|
var db = GetConnect().GetDatabase(_defaultDB);
|
|
|
|
return db.StringSet(key, value, expiry);
|
|
|
|
return db.StringSet(key, value, expiry);
|
|
|
@ -124,6 +137,7 @@ public class RedisHelper : IDisposable
|
|
|
|
var db = GetConnect().GetDatabase(_defaultDB);
|
|
|
|
var db = GetConnect().GetDatabase(_defaultDB);
|
|
|
|
return await db.StringSetAsync(key, value);
|
|
|
|
return await db.StringSetAsync(key, value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool Remove(string key)
|
|
|
|
public bool Remove(string key)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var db = GetConnect().GetDatabase(_defaultDB);
|
|
|
|
var db = GetConnect().GetDatabase(_defaultDB);
|
|
|
|