We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9a9da65 commit 418650dCopy full SHA for 418650d
src/main/java/org/b3log/symphony/util/QiniuTextCensor.java
@@ -27,11 +27,18 @@
27
28
import java.security.MessageDigest;
29
import java.security.NoSuchAlgorithmException;
30
-import java.util.HashMap;
+import java.util.Collections;
31
+import java.util.LinkedHashMap;
32
+import java.util.Map;
33
34
public class QiniuTextCensor {
35
- 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
+ });
42
43
public static JSONObject censor(String text) {
44
if (text.isEmpty()) {
0 commit comments