Added #1875 Remove no longer accessed items from cache after certain amount of time

This commit is contained in:
Jindra Petřík
2022-11-17 08:49:30 +01:00
parent 77a6b6a019
commit 202e66ea1d
12 changed files with 103 additions and 19 deletions

View File

@@ -47,9 +47,9 @@ public class IdentifiersDeobfuscation {
private final HashMap<String, Integer> typeCounts = new HashMap<>();
private static final Cache<String, String> as2NameCache = Cache.getInstance(false, true, "as2_ident");
private static final Cache<String, String> as2NameCache = Cache.getInstance(false, true, "as2_ident", true);
private static final Cache<String, String> as3NameCache = Cache.getInstance(false, true, "as3_ident");
private static final Cache<String, String> as3NameCache = Cache.getInstance(false, true, "as3_ident", true);
public static final String VALID_FIRST_CHARACTERS = "\\p{Lu}\\p{Ll}\\p{Lt}\\p{Lm}\\p{Lo}_$";

View File

@@ -341,16 +341,16 @@ public final class SWF implements SWFContainerItem, Timelined {
private final IdentifiersDeobfuscation deobfuscation = new IdentifiersDeobfuscation();
@Internal
private final Cache<String, SerializableImage> frameCache = Cache.getInstance(false, false, "frame");
private final Cache<String, SerializableImage> frameCache = Cache.getInstance(false, false, "frame", true);
@Internal
private final Cache<CharacterTag, RECT> rectCache = Cache.getInstance(true, true, "rect");
private final Cache<CharacterTag, RECT> rectCache = Cache.getInstance(true, true, "rect", true);
@Internal
private final Cache<SHAPE, ShapeExportData> shapeExportDataCache = Cache.getInstance(true, true, "shapeExportData");
private final Cache<SHAPE, ShapeExportData> shapeExportDataCache = Cache.getInstance(true, true, "shapeExportData", true);
@Internal
private final Cache<SoundInfoSoundCacheEntry, byte[]> soundCache = Cache.getInstance(false, false, "sound");
private final Cache<SoundInfoSoundCacheEntry, byte[]> soundCache = Cache.getInstance(false, false, "sound", true);
@Internal
public final AS2Cache as2Cache = new AS2Cache();

View File

@@ -27,9 +27,9 @@ import com.jpexs.helpers.Cache;
*/
public class AS2Cache {
private final Cache<ASMSource, HighlightedText> cache = Cache.getInstance(true, false, "as2");
private final Cache<ASMSource, HighlightedText> cache = Cache.getInstance(true, false, "as2", false);
private final Cache<ASMSource, ActionList> pcodeCache = Cache.getInstance(true, true, "as2pcode");
private final Cache<ASMSource, ActionList> pcodeCache = Cache.getInstance(true, true, "as2pcode", false);
public void clear() {
pcodeCache.clear();

View File

@@ -26,7 +26,7 @@ import com.jpexs.helpers.Cache;
*/
public class AS3Cache {
private final Cache<ScriptPack, HighlightedText> cache = Cache.getInstance(true, false, "as3");
private final Cache<ScriptPack, HighlightedText> cache = Cache.getInstance(true, false, "as3", false);
public void clear() {
cache.clear();

View File

@@ -787,6 +787,10 @@ public final class Configuration {
@ConfigurationDefaultBoolean(true)
@ConfigurationCategory("display")
public static ConfigurationItem<Boolean> autoPlayPreviews = null;
@ConfigurationDefaultInt(5 * 60 * 1000)
@ConfigurationCategory("limit")
public static ConfigurationItem<Integer> maxCachedTime = null;
private enum OSId {
WINDOWS, OSX, UNIX

View File

@@ -31,7 +31,7 @@ import java.util.logging.Logger;
public class AbstractDocs {
protected static Cache<String, String> docsCache = Cache.getInstance(false, true, "abstractDocsCache");
protected static Cache<String, String> docsCache = Cache.getInstance(false, true, "abstractDocsCache", false);
protected static String htmlFooter() {
StringBuilder sb = new StringBuilder();