@SuppressWarnings("unchecked")
    public <K, V> Cache<K, V> getCache(String name) throws IllegalArgumentException, CacheException {
        if (!StringUtils.hasText(name)) {
            throw new IllegalArgumentException("Cache name cannot be null or empty.");
        }

        Cache<K, V> cache;

        cache = (Cache<K, V>) caches.get(name);
        if (cache == null) {
            cache = createCache(name);
            Cache<K, V> existing = (Cache<K, V>) caches.putIfAbsent(name, cache);
            if (existing != null) {
                cache = existing;
            }
        }

        //noinspection unchecked
        return cache;
    }
Returns the cache with the specified {@code name}.  If the cache instance does not yet exist, it will be lazily
created, retained for further access, and then returned.

@param name the name of the cache to acquire.
@return the cache with the specified {@code name}.
@throws IllegalArgumentException if the {@code name} argument is {@code null} or does not contain text.
@throws CacheException           if there is a problem lazily creating a {@code Cache} instance.
cache/src/main/java/org/apache/shiro/cache/AbstractCacheManager.java