Skip to content

Commit 418650d

Browse files
committed
🎨 文本接入AI检测
1 parent 9a9da65 commit 418650d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/main/java/org/b3log/symphony/util/QiniuTextCensor.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,18 @@
2727

2828
import java.security.MessageDigest;
2929
import java.security.NoSuchAlgorithmException;
30-
import java.util.HashMap;
30+
import java.util.Collections;
31+
import java.util.LinkedHashMap;
32+
import java.util.Map;
3133

3234
public class QiniuTextCensor {
3335

34-
private static HashMap<String, JSONObject> cache = new HashMap<>();
36+
public static final Map<String, JSONObject> cache = Collections.synchronizedMap(new LinkedHashMap<>() {
37+
@Override
38+
protected boolean removeEldestEntry(Map.Entry eldest) {
39+
return size() > 2000;
40+
}
41+
});
3542

3643
public static JSONObject censor(String text) {
3744
if (text.isEmpty()) {

0 commit comments

Comments
 (0)