title: How can i get the cacheManager from shiro framework in any part of application
body: <p>How can I get a reference to the cacheManager object in the Shiro framework in any part of my application? For example, I want to remove the old user data that was cached during the removal of a user or updating its permission.
  Right now I am handling it following way</p>
  
  <pre><code>public void cleanUserCache(final String userName) {
          final EmbeddedCacheManager embeddedCacheManager = securityRealmsProducer.getEmbeddedCacheManger();
          final Cache&lt;Object, Object&gt; authenticationCache = embeddedCacheManager.getCache("JPA-Auth-Realm.authenticationCache");
          final Cache&lt;Object, Object&gt; authrizationCache = embeddedCacheManager.getCache("JPA-Auth-Realm.authorizationCache");
          final Object userAuthenticationInfo = authenticationCache.get(userName);
          if (userAuthenticationInfo != null) {
              authenticationCache.remove(userName);
              final SimpleAuthenticationInfo principle = (SimpleAuthenticationInfo) userAuthenticationInfo;
              final SimplePrincipalCollection simple = (SimplePrincipalCollection) principle.getPrincipals();
              authorizationCache.remove(simple);
          }
      }
  </code></pre>