Java:自动内存

标签 java python annotations decorator memoization

我的代码中有一些函数使用内存很有意义(似乎甚至是强制性的)。

我不想分别为每个函数手动实现它。有没有什么方法(例如 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/

相关文章:

annotations - iOS 4.2 中的 map 注释和 MKMapView 有问题吗?

hibernate - JPA 注释 = EJB3 注释 = Hibernate 注释?

java - 如何解决越界异常错误?

java - 使用StanfordCoreNLP提取两个实体之间的关系

python - Python 中数组的 2D 和 3D 散点直方图

python - 使用 DataFrame.to_dict 时 dtype 发生变化

python - Pandas groupby : retrieve columns on which data is grouped

java - 在哨兵不工作时做(java)

Java - 保存草图

java - 为什么@NotNull 注释不删除警告?