|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.lang.Thread
lazyj.cache.Cache
public class Cache
This class is a central point where all the data caching structure can be stored, for universal access.
Any structure registered here will be automatically refreshed and it will
be visible to everybody provided they know the registration key.
To register something into this repository you need to have:
CacheElement
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.lang.Thread |
|---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
| Field Summary |
|---|
| Fields inherited from class java.lang.Thread |
|---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.lang.Thread |
|---|
activeCount, checkAccess, 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 |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Method Detail |
|---|
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 registration
public 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.Runnablerun in class java.lang.Thread
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||