00:00/00:00

实现InitializingBean接口的afterPropertiesSet方法,当启动时将所有需要缓存的数据缓存到redis中

@Controller
@RequestMapping("/test")
public class TestController implements InitializingBean {

    @Autowired
    RedisService redisService;


    /**
     * 系统初始化
     * */
    public void afterPropertiesSet() throws Exception {
        List<User> user= userService.getList();
        if(user== null) {
            return;
        }
        for(User u: user) {
            redisService.set("user", ""+user.getId(), user);
        }
    }
    }

You Might Also Like

No Comments

Leave a Reply