1
votes

I use ehcache-spring-annotations 1.2.0 (Google code) with Spring 3.0.2.

I have annotated a DAO method with @Cacheable. The caching actually takes place (verified with logging and ehCache mbean). However, the method still takes 50 ms to 100 ms to execute when there is a cache hit.

At first, I suspected that a Hibernate transaction was still being created, so I created a separate class that uses the @Cacheable annotations, and delegates to the original DAO that uses the @Transactional annotation. It does not make any noticeable difference.

Am I doing something wrong, or do I have to lower my expectations?

1

1 Answers

1
votes

You expectations are are not too high, I would expect 0-1 ms for cache hits. These possibilities come to mind:

(1) If there is a custom key generator, check for a bug/slowdown in it. (2) Verify that the cache settings are such that this cache is NOT being forced to disk only.