X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2FdbObjects%2FObjectCache.java;h=e06f84f84a57fd0fde3bafe5d8066b9d6efc08d0;hp=5f44542200458467c535b959266dde527e4a098b;hb=8989aa1f0dca5ed1b6ef8ba5f786f5192f8bf950;hpb=e409ba881965634f63f0b67824bc93dda4ec4327 diff --git a/src/org/cacert/gigi/dbObjects/ObjectCache.java b/src/org/cacert/gigi/dbObjects/ObjectCache.java index 5f445422..e06f84f8 100644 --- a/src/org/cacert/gigi/dbObjects/ObjectCache.java +++ b/src/org/cacert/gigi/dbObjects/ObjectCache.java @@ -2,11 +2,18 @@ package org.cacert.gigi.dbObjects; import java.lang.ref.WeakReference; import java.util.HashMap; +import java.util.HashSet; public class ObjectCache { HashMap> hashmap = new HashMap<>(); + private static HashSet> caches = new HashSet<>(); + + protected ObjectCache() { + caches.add(this); + } + public void put(T c) { hashmap.put(c.getId(), new WeakReference(c)); } @@ -18,4 +25,10 @@ public class ObjectCache { } return null; } + + public static void clearAllCashes() { + for (ObjectCache objectCache : caches) { + objectCache.hashmap.clear(); + } + } }