登录session是缓存到ehcache中和redis中,所以我现在另一个系统中读取缓存判断登录
@Bean
public LCacheManager cacheManager() {
LCacheManager cacheManager = new LCacheManager();
cacheManager.setJedisAgent(jedisAgent());
cacheManager.setLevel1(ehCacheManager());
cacheManager.setLevel2(redisCacheManager());
return cacheManager;
}
@Bean
public JedisAgent jedisAgent() {
PropertiesProxy proxy = new PropertiesProxy();
proxy.set("redis.mode", "normal");
proxy.set("redis.host", "192.168.0.117");
proxy.set("redis.database", "2");
proxy.set("redis.port", "6379");
proxy.set("redis.password", "hxcf9966");
proxy.set("redis.timeout", "2000");
JedisAgent jedisAgent = new JedisAgent();
jedisAgent.setConf(proxy);
return jedisAgent;
}
@Bean
public RedisCacheManager redisCacheManager() {
RedisCacheManager redisCacheManager = new RedisCacheManager();
redisCacheManager.setDebug(true);
redisCacheManager.setMode("kv");
redisCacheManager.setTtl(1800);
return redisCacheManager;
}
@Bean
public EhCacheManager ehCacheManager() {
EhCacheManager ehCacheManager = new EhCacheManager();
ehCacheManager.setCacheManagerConfigFile("classpath:ehcache.xml");
return ehCacheManager;
}
@Autowired
private LCacheManager cacheManager;
@Test
public void tests() throws Exception {
Cache<String, Deque<Serializable>> cache = cacheManager.getCache("shiro-activeSessionCache");
// String result = HttpUtil.post("http://192.168.0.33:8080/isLogin", "chUserId=18673196119", HttpUtil.CHARSET);
cache.get("18673196219");
}
这样试了下没用