Today, I saw an article, explaining how to use Java dynamic proxy implementation to cache
http://www.matrix.org.cn/Article/487.html
After reading the following understanding:
First of all, his cache is targeted
InvocationHandler implements an instance of an object to caches instead of global. Each Memoizer.Memoize method call will regenerate an Memoizer instance. public static Object memoize (Object object) {return Proxy.newProxyInstance (. object.getClass () getClassLoader (), object.getClass () getInterfaces (), new Memoizer (object).);} method object.getClass (). GetInterfaces () usage is flexible, realizing dynamic instances of any objects and interfaces. This is also an implementation of AOP based on dynamic agents.