gpt4 book ai didi

xpages - 测试 View 是否已被回收的最便宜的方法是什么?

转载 作者:行者123 更新时间:2023-12-01 11:49:33 27 4
gpt4 key购买 nike

我有一个缓存 bean,用于在应用程序中查找/存储有关对象的信息。我想尽可能少地获取 View ,就像我想象的那样,每个 Database.getView 都需要付出一定的代价。

触发“View has been recycled”的成本最低的方法是什么?

最佳答案

设计用于测试各种 Domino 对象的测试器类怎么样?

如果对象被回收,您可以执行一个会抛出异常的操作——而不是仅仅测试 null。下面的代码会起作用吗,还是我过于简单化了?

package com.azlighthouse.sandbox;

import lotus.domino.Database;
import lotus.domino.Document;
import lotus.domino.NotesException;

public class NPHchecker {

public static boolean isRecycled(Document source, boolean printStackTrace) {
try {
return (source.getUniversalID().length() > 0);
} catch (NotesException e) {
if (printStackTrace)
e.printStackTrace();
return true;
}
} // isRecycled(Document, boolean)

public static boolean isRecycled(Database source, boolean printStackTrace) {
try {
return (source.getReplicaID().length() > 0);
} catch (NotesException e) {
if (printStackTrace)
e.printStackTrace();
return true;
}
} // isRecycled(Database, boolean)


} // NPHchecker

关于xpages - 测试 View 是否已被回收的最便宜的方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12740889/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com