| | |
| | | package com.java110.core.factory; |
| | | |
| | | import com.java110.dto.communitySetting.CommunitySettingDto; |
| | | import com.java110.dto.community.CommunitySettingDto; |
| | | import com.java110.intf.community.ICommunitySettingInnerServiceSMO; |
| | | import com.java110.po.community.CommunitySettingPo; |
| | | import com.java110.utils.cache.BaseCache; |
| | | import com.java110.utils.factory.ApplicationContextFactory; |
| | | import com.java110.utils.util.SerializeUtil; |
| | | import com.java110.utils.util.StringUtil; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import com.java110.core.log.LoggerFactory; |
| | | import org.springframework.beans.factory.NoSuchBeanDefinitionException; |
| | | import redis.clients.jedis.Jedis; |
| | | import com.java110.utils.cache.Jedis; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | return communitySettingDto.getSettingValue(); |
| | | } |
| | | |
| | | /** |
| | | * 查询设置值 |
| | | * |
| | | * @param communityId |
| | | * @param key |
| | | * @return |
| | | */ |
| | | public static String getRemark(String communityId, String key) { |
| | | Jedis redis = null; |
| | | CommunitySettingDto communitySettingDto = null; |
| | | try { |
| | | redis = getJedis(); |
| | | Object object = SerializeUtil.unserialize(redis.get((communityId + "_" + key + "_community_setting").getBytes())); |
| | | if (object == null) {//这里存在并发问题,但是 等于查询了多次 然后多次写缓存,作者认为 这种应该比加全局锁效率高些 |
| | | communitySettingDto = getCommunitySettingFromDb(communityId, key, redis); |
| | | } else { |
| | | communitySettingDto = (CommunitySettingDto) object; |
| | | } |
| | | } finally { |
| | | if (redis != null) { |
| | | redis.close(); |
| | | } |
| | | } |
| | | |
| | | if (communitySettingDto == null) { |
| | | return null; |
| | | } |
| | | |
| | | return communitySettingDto.getRemark(); |
| | | } |
| | | |
| | | public static CommunitySettingDto getCommunitySettingFromDb(String communityId, String key) { |
| | | Jedis redis = null; |
| | | try { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 手工保存数据 |
| | | * |
| | | * @param communitySettingDto |
| | | */ |
| | | public static void deleteCommunitySetting(CommunitySettingPo communitySettingPo) { |
| | | Jedis redis = null; |
| | | try { |
| | | redis = getJedis(); |
| | | redis.del((communitySettingPo.getCommunityId() + "_" + communitySettingPo.getSettingKey() + "_community_setting").getBytes()); |
| | | } finally { |
| | | if (redis != null) { |
| | | redis.close(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询设置值 |
| | | * |
| | | * @param communityId |