接着上一篇博客来讲:Spring Boot整合jpa,Shiro进行权限管理
Shiro默认整合了EhCache,来实现缓存,如果我们想用redis替换EhCache来实现缓存怎么做了?我们可以从Shiro的源码来找到一些端倪。我们可以模拟EhCacheManager的实现方式,EhCacheManager类定义如下:
public class EhCacheManager implements CacheManager, Initializable, Destroyable {
}
我们从上面的代码可以看到,最终要的是实现了CacheManager接口,该接口很简单,只有一个方法:
public interface CacheManager {
/**
* Acquires the cache with the specified <code>name</code>. If a cache does not yet exist with that name, a new one
* will be created with that name and returned.
*
* @param name the name of the cache to a