示例#1
0
 /// <summary>
 /// 以对象方式存储
 /// </summary>
 /// <typeparam name="T">实体</typeparam>
 /// <param name="key">键</param>
 /// <param name="value">值</param>
 /// <param name="expiry">过期时间</param>
 /// <returns></returns>
 public bool Set <T>(string key, T value, TimeSpan?expiry = default(TimeSpan?))
 {
     return(GetDatabase().StringSet(MergeKey(key), RedisUtility.ConvertToStr(value), expiry));
 }
示例#2
0
 /// <summary>
 /// 存储指定类型数据(异步)
 /// </summary>
 /// <param name="dbNum">数据库号码</param>
 /// <param name="key">键</param>
 /// <param name="field">域</param>
 /// <param name="value">值</param>
 /// <returns></returns>
 public async Task <bool> SetHashAsync <T>(int dbNum, string key, string field, T value)
 {
     return(await GetDatabase(dbNum).HashSetAsync(MergeKey(key), field, RedisUtility.ConvertToStr(value)));
 }
示例#3
0
 /// <summary>
 /// 存储指定类型数据
 /// </summary>
 /// <param name="dbNum">数据库号码</param>
 /// <param name="key">键</param>
 /// <param name="field">域</param>
 /// <param name="value">值</param>
 /// <returns></returns>
 public bool SetHash <T>(int dbNum, string key, string field, T value)
 {
     return(GetDatabase(dbNum).HashSet(MergeKey(key), field, RedisUtility.ConvertToStr(value)));
 }
示例#4
0
 /// <summary>
 /// 存储指定类型数据
 /// </summary>
 /// <param name="dbNum">数据库号码</param>
 /// <param name="key">键</param>
 /// <param name="field">域</param>
 /// <param name="value">值</param>
 /// <param name="expiry">过期时间</param>
 /// <returns></returns>
 public bool SetHash <T>(int dbNum, string key, string field, T value, TimeSpan expiry)
 {
     GetDatabase(dbNum).HashSet(MergeKey(key), field, RedisUtility.ConvertToStr(value));
     return(GetDatabase().KeyExpire(MergeKey(key), expiry));
 }
示例#5
0
 /// <summary>
 /// 以对象方式存储(异步)
 /// </summary>
 /// <typeparam name="T">实体</typeparam>
 /// <param name="dbNum">数据库号码</param>
 /// <param name="key">键</param>
 /// <param name="value">值</param>
 /// <param name="expiry">过期时间</param>
 /// <returns></returns>
 public async Task <bool> SetAsync <T>(int dbNum, string key, T value, TimeSpan?expiry = default(TimeSpan?))
 {
     return(await GetDatabase(dbNum).StringSetAsync(MergeKey(key), RedisUtility.ConvertToStr(value), expiry));
 }