X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2FdbObjects%2FObjectCache.java;h=0d9fc14ba51b4f2d0e4005a3977367bdd3c66ff5;hp=d1e41f82e3baaa0b359e6d55b1283fb81e0b85c4;hb=b47144d6f3bf6b6eb1ec477de9d2af38256f074f;hpb=da72882d9ff14bd4077d9f71ae134a67581c49cb diff --git a/src/org/cacert/gigi/dbObjects/ObjectCache.java b/src/org/cacert/gigi/dbObjects/ObjectCache.java index d1e41f82..0d9fc14b 100644 --- a/src/org/cacert/gigi/dbObjects/ObjectCache.java +++ b/src/org/cacert/gigi/dbObjects/ObjectCache.java @@ -6,16 +6,17 @@ import java.util.HashSet; public class ObjectCache { - private HashMap> hashmap = new HashMap<>(); + private final HashMap> hashmap = new HashMap<>(); - private static HashSet> caches = new HashSet<>(); + private static final HashSet> caches = new HashSet<>(); protected ObjectCache() { caches.add(this); } - public void put(T c) { + public T put(T c) { hashmap.put(c.getId(), new WeakReference(c)); + return c; } public T get(int id) { @@ -27,7 +28,7 @@ public class ObjectCache { } public static void clearAllCaches() { - for (ObjectCache objectCache : caches) { + for (ObjectCache objectCache : caches) { objectCache.hashmap.clear(); } }