title: Apache shiro - how do I know that caching is working for authorization?
body: <p>I am using Apache Shiro in my Tomcat and I want to enable caching of authorization through EhCache.</p>
  
  <p>What I've done is adding these two lines in shiro.ini:</p>
  
  <pre>
  cacheManager = org.apache.shiro.cache.ehcache.EhCacheManager
  securityManager.cacheManager = $cacheManager
  </pre>
  
  <p>and copied ehcache-core-2.5.1.jar in my WEB-INF/lib directory. For the authorization, I have implemented a custom Realm that reads the permissions from a MySQL Databaase. So I want to enable the cache in order to reduce as much as possible the queries to the database... I have to mention that I am not familiar with EhCache and I only want to enable caching of the authorization!</p>
  
  <p>If I've understood the Shiro documentation correctly, the above are enough to enable the caching - however I am not seeing that :(</p>
  
  <p>Tomcat Starts without exceptions and, in a test JSP I am using authorization works ok at first. After if I make a change to the permissions of the database I see that the test JSP is immediately aware of the change! I was expecting that the test JSP would return the values from the cache... Can you tell me what could be wrong ? Also, is there a way to find out if EhCache is actually called and how it behaves (if logging needs to be enabled I'd be grateful if you gave me detailed information because I am not very familiar with that).</p>
  
  <p><strong>Update:</strong> I also have to mention that I added the line </p>
  
  <pre>System.out.println("Caching is enabled " + isCachingEnabled() );</pre>
  
  <p>in the initialization of my custom realm and I get true!</p>
  
  <p>TIA,</p>
  
  <p>Serafeim</p>