Since UserReaml indirectly inherits AuthenticatingRealm, the following two methods are run when cache is called, So you need to set up this. AuthenticationCachingEnabled && isCachingEnabled () this property or method corresponding properties to open the cache.

Private Cache<Object, AuthenticationInfo>getAvailableAuthenticationCache() {
        Cache<Object, AuthenticationInfo> cache = getAuthenticationCache();
        boolean authcCachingEnabled = isAuthenticationCachingEnabled();
        if (cache == null && authcCachingEnabled) {
            cache = getAuthenticationCacheLazy();
        }
        return cache;
    }

public boolean isAuthenticationCachingEnabled() {// Notice herereturn this.authenticationCachingEnabled && isCachingEnabled();
    }
Copy the code