T - The cache entry type.E - The exception type.public abstract class PerThreadCache<T,E extends Exception> extends Object
| Constructor and Description |
|---|
PerThreadCache(int maxSize)
Initialises the thread-local cache with the given maximum size (i.e., number of threads).
|
| Modifier and Type | Method and Description |
|---|---|
T |
getInstanceForCurrentThread()
Fetches an instance of the resource from the cache for the current thread.
|
protected abstract T |
initialValue()
Method will be called to initialise a fresh instance of the underlying resource when one is not found in the
cache.
|
public PerThreadCache(int maxSize)
maxSize - the maximum number of instances to cache.public final T getInstanceForCurrentThread() throws E extends Exception
initialValue() to create one and then adds it to the cache.
If this causes the cache to exceed the configured maximum size then the least recently used (LRU)
entry will be deleted from the cache to preserve the capacity restriction.Copyright © 2010–2023 Open Identity Platform Community. All rights reserved.