iyuohz / ehcache-spring-annotations

Automatically exported from code.google.com/p/ehcache-spring-annotations
0 stars 0 forks source link

Add support for caching of return values from static method calls #51

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Defined a new cache to ehcache.xml such as:

  <cache
    name="staticCache"
    maxElementsInMemory="16384"
    eternal="false"
    overflowToDisk="false"
    timeToLiveSeconds="60" />

2. Added the required imports to the class in question and a @Cacheable 
annotation to a static function call:

@Cacheable(cacheName = "staticCache")
public static String getBody(URI uri) {
  ...
}

What is the expected output? What do you see instead?

No caching.

What version of the product are you using? On what operating system?

Tomcat 6.0.18 and ehcache-spring-annotations-1.1.2.jar.

Please provide any additional information below.

It simply may be due to my incompetence, but I was not able get 
ehcache-spring-annotations to cache return values from static method calls. 
Caching of return values of non-static methods works as expected.

Original issue reported on code.google.com by mikko.a....@gmail.com on 8 Oct 2010 at 11:47

GoogleCodeExporter commented 9 years ago
Static methods cannot be cached. The way aspects work in Spring is by adding a 
wrapper class (a proxy) to the annotated class. There is no way in Java to add 
a wrapper to a static method.

Original comment by eric.dalquist on 8 Oct 2010 at 12:23