title: How to apply cache to spring oauth ClientDetailsService
body: <p>this is more an answer than a question - documenting it for other people that might look for this.</p>
  
  <p>we are using Spring JdbcClientDetailsService and in current version 2.0.5 it produce more than 1 query per resource request/token request, and might cause some performance issue.
  so we followed spring team advice (in release 2.0.3) to put cache on this service </p>
  
  <p>we already had a ehcache setup so all i needed to do is several aop declarations.</p>
  
  <p><strong>update</strong>
  now i was looking into putting a cache on the token and authentication objects as they are also queried a lot. but it turns out there is a problem with TokenStore.readAuthentication - i guess there is a problem with method overloading, cause one signature is spring and the other is token object.</p>
  
  <p>i've tried something like this but it didn't work </p>
  
  <pre><code>&lt;aop:advisor advice-ref="authByTokenIdAdvice" pointcut="execution(* org.springframework.security.oauth2.provider.token.TokenStore.readAuthentication(String))"/&gt;
  </code></pre>
  
  <p>anyone has an idea ?</p>