Package com.atlassian.confluence.cache
Class ThreadLocalCache
- java.lang.Object
-
- com.atlassian.confluence.cache.ThreadLocalCache
-
public class ThreadLocalCache extends Object
A generic cache for "stuff" that is only needed for the lifetime of a web request or scheduled job. The most important rule for this cache is use custom types for keys. If you use some generic key type like a String, you will inevitably clobber someone else's cached data.Don't use the ThreadLocalCache directly: use the ThreadLocalCacheAccessor to give you a typesafe container around the cache.
- See Also:
ThreadLocalCacheAccessor
-
-
Constructor Summary
Constructors Constructor Description ThreadLocalCache()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
dispose()
Clean up the cache for the current thread.static void
flush()
Flush the contents of the cache, but do not clean up the cache itself.static Object
get(Object key)
Retrieve an object from the cachestatic void
init()
Initialise the cache for the current threadstatic boolean
isInit()
static void
put(Object key, Object value)
Put an object in the cache
-
-
-
Method Detail
-
put
public static void put(Object key, Object value)
Put an object in the cache- Parameters:
key
- the cache keyvalue
- the value to cache
-
get
public static Object get(Object key)
Retrieve an object from the cache- Parameters:
key
- the cache key- Returns:
- the appropriate cached value, or null if no value could be found, or the cache is not initialised
-
init
public static void init()
Initialise the cache for the current thread
-
isInit
public static boolean isInit()
-
dispose
public static void dispose()
Clean up the cache for the current thread.
-
flush
public static void flush()
Flush the contents of the cache, but do not clean up the cache itself.
-
-