All Downloads are FREE. Search and download functionalities are using the official Maven repository.

group.rober.base.adapter.CacheManagerAdapter Maven / Gradle / Ivy

package group.rober.base.adapter;


import group.rober.runtime.lang.RoberException;
import org.apache.shiro.cache.Cache;
import org.apache.shiro.cache.CacheException;
import org.apache.shiro.cache.CacheManager;


public class CacheManagerAdapter implements CacheManager{
    private final org.springframework.cache.CacheManager cacheManager;

    public CacheManagerAdapter(org.springframework.cache.CacheManager cacheManager) {
        this.cacheManager = cacheManager;
    }

    @Override
    public  Cache getCache(String name) throws CacheException {
        org.springframework.cache.Cache cache = cacheManager.getCache(name);
        if(cache == null){
            throw new RoberException("没有获取到[{0}]的缓存,请检查缓存配置",name);
        }
        return new CacheAdapter<>(cache);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy