java中如何在项目启动时将一些配置信息加载到Redis中

一、在项目启动时将一些数据库配置信息加载到Redis中

 

 /**
     * 初始化配置参数到缓存中
     */
    @PostConstruct
    private void init() {
        Map configMap = new HashMap<>();
        List list = attributionConfigDao.selectList(new LambdaQueryWrapper());
        if (CheckUtils.isNotEmpty(list)){
            for (Config attributionConfig : list) {
                configMap.put(attributionConfig.getSysOrgId(),attributionConfig);
            }
            redisTemplate.opsForHash().putAll("attributionMap", configMap);
        }

    }

点赞加关注,持续更新中!!!

你可能感兴趣的:(java,Redis,java,redis,开发语言)