我的代码中有一些函数使用内存很有意义(似乎甚至是强制性的)。
我不想分别为每个函数手动实现它。有没有什么方法(例如 like in Python)我可以只使用注释或做其他事情,这样我就可以在我想要的那些函数上自动获得它?
最佳答案
Spring 3.1 现在提供了一个 @Cacheable
annotation ,正是这样做的。
As the name implies, @Cacheable is used to demarcate methods that are cacheable - that is, methods for whom the result is stored into the cache so on subsequent invocations (with the same arguments), the value in the cache is returned without having to actually execute the method.
关于Java:自动内存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3934777/