/// <summary> /// 将对象设置到缓存中 /// </summary> /// <param name="entity"></param> public static void SetCache(BaseUserLogonExtendEntity entity) { string key = string.Empty; if (entity != null && !string.IsNullOrWhiteSpace(entity.Id.ToString())) { using (var redisClient = PooledRedisHelper.GetUserClient()) { key = cacheKeyPrefix + entity.Id; redisClient.Set <BaseUserLogonExtendEntity>(key, entity, DateTime.Now.AddMinutes(10)); } } }
/// <summary> /// 根据key值获取缓存对象 /// </summary> /// <param name="key"></param> /// <returns></returns> private static BaseUserLogonExtendEntity GetCache(string key) { BaseUserLogonExtendEntity result = null; if (!string.IsNullOrWhiteSpace(key)) { using (var redisClient = PooledRedisHelper.GetUserClient()) { result = redisClient.Get <BaseUserLogonExtendEntity>(key); } } return(result); }