public class Cache
extends java.lang.Thread
CacheElement
Modifier and Type | Method and Description |
---|---|
static CacheElement<?,?> |
get(java.lang.String sKey)
Use this method to retrieve an entry you are interested in.
|
static java.util.Set<java.lang.String> |
getKeySet()
Method to discover all the registered entries.
|
static void |
refresh(java.lang.String sKey)
Force a refresh of a cache entry.
|
static void |
register(java.lang.String sKey,
CacheElement<?,?> ce)
Register an element into the Cache.
|
void |
run()
This thread will take each entry that expires and refreshes it.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
public static final void register(java.lang.String sKey, CacheElement<?,?> ce)
CacheElement.refresh()
will be called before the actual registration, so you don't have to
initialize the entry yourself. A construction like:static{ Cache.register("unique key", new CacheElementImplementation()); }
null
for the ce
parameter.sKey
- unique keyce
- cached structurepublic static final CacheElement<?,?> get(java.lang.String sKey)
CacheElement ce = Cache.get("unique key"); if (ce!=null){ SomeObject so = (SomeObject) ce.get("internal name"); }
sKey
- the unique key given at registrationpublic static final void refresh(java.lang.String sKey)
CacheElement
directly because the Cache will not be aware of the call and will try to update itself the
entry after an incorrect period of time. Not a big deal though :)sKey
- the unique key to refreshpublic static final java.util.Set<java.lang.String> getKeySet()
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread