Class ClusterCaches
java.lang.Object
com.kingsrook.qqq.backend.core.cluster.ClusterCaches
The registry of in-memory caches (static Memoizations and the like). When a
cache goes stale on one node, it is cleared on every node: ClusterBus event
memo-invalidate, and for session-keyed caches also session-ended.
Every static cache registers, inline where it is declared:
private static final Memoization<Integer, Script> SCRIPTS = ClusterCaches.shared("scripts.byId", new Memoization<>(), Integer::valueOf);
private static final Memoization<String, Constructor<?>> CTORS = ClusterCaches.nodeLocal(new Memoization<>(), "classes are the same on every node");
ClusterCacheAudit, used by tests, fails on a static Memoization that did not
register.-
Method Summary
Modifier and TypeMethodDescriptionstatic voidinvalidate(String name) Clear a cache on every node.static voidinvalidateKey(String name, String key) Clear one key of a cache on every node (null key: all of it).static booleanisRegistered(Object cache) Whether a cache object was registered (shared or node-local).static <T> TDeclare a cache that is correct per node: it holds what is the same on every node (classes, code, provider metadata).static voidsessionEnded(String sessionUUID) A session ended: clear session-keyed caches on every node.static <V> Memoization<String, V> sessionKeyed(String name, Memoization<String, V> memoization) Register a shared cache keyed by session UUID: also cleared (for that session) when a session ends on any node.static <K,V> Memoization <K, V> shared(String name, Memoization<K, V> memoization, Function<String, K> keyParser) Register a cache that must be cleared on every node when it is invalidated. keyParser turns an event's key text back into the cache's key type (null: a key invalidation clears everything).static <T> TRegister any other in-memory cache by its clear actions (clearKey may be null: then a key invalidation clears everything).
-
Method Details
-
sessionKeyed
public static <V> Memoization<String,V> sessionKeyed(String name, Memoization<String, V> memoization) Register a shared cache keyed by session UUID: also cleared (for that session) when a session ends on any node. -
nodeLocal
Declare a cache that is correct per node: it holds what is the same on every node (classes, code, provider metadata). The reason documents why. -
isRegistered
Whether a cache object was registered (shared or node-local). -
invalidate
Clear a cache on every node. -
invalidateKey
-
sessionEnded
A session ended: clear session-keyed caches on every node.