java110
2021-11-22 4065251a85956f6a32f7fd35317446dfed7cbdcd
java110-core/src/main/java/com/java110/core/factory/CommunitySettingFactory.java
@@ -53,6 +53,37 @@
        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 {