记一下Shiro重构之ShiroRedisCommandLineRunner

2023-08-17 15:36:22 浏览数 (1)

代码语言:javascript复制
package com.ccb.web.shiro;

import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;


/**
 * Redis初始化的时候清空用户信息
 * 服务器宕机后,redis存储缓存信息与本地缓存不同步
 *
 * @author huan
 * @version 2.8.2
 * @Date 2019/8/13$
 */
@Component
@Slf4j
public class ShiroRedisCommandLineRunner implements CommandLineRunner {
    @Autowired
    RedisSessionDAO redisSessionDAO;

    @Override
    public void run(String... args) {
        redisSessionDAO.clearCache();
        log.info("redis缓存清除成功!");
    }
}

0 人点赞