The method of custom cache key when using shiro redis cache.

  As business needs, ready to use with authorization to operate a redis in different projects, so that must be consistent redis two different system calls in the key,

After searching online for a long time we did not find the results, so step by step, breakpoint look, finally found shiro set rediskey method.

	@Bean
	public MyRealm myRealm() {
		MyRealm myRealm = new MyRealm();
		myRealm.setAuthorizationCacheName("com.manyun");
		return myRealm;
	}

  You can also modify the prefix key

@Bean
	public RedisCacheManager cacheManager() {
		RedisCacheManager redisCacheManager = new RedisCacheManager();
		redisCacheManager.setRedisManager (redisManager ());
		redisCacheManager.setKeyPrefix("aaa");
		return redisCacheManager;
	}

  

Guess you like

Origin www.cnblogs.com/huashuohehe/p/11985218.html