public abstract class SimpleCachingDataAdapter<T,A extends Decoder<T>> extends DataAdapter<T,A>
DataAdapter that manages a cache in between the adapter and the data source.
This is an on-heap memory cache with a finite capacity and an LRU eviction policy
Furthermore, values uses SoftReference to give the GC a chance to collect the cached elements
if the memory pressure becomes too high.
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_CACHE_SIZE |
closed| Constructor and Description |
|---|
SimpleCachingDataAdapter()
Initializes a new instance of the
SimpleCachingDataAdapter class |
SimpleCachingDataAdapter(int maxCacheEntries)
Initializes a new instance of the
SimpleCachingDataAdapter class with the specified maximum number of entries |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
java.io.InputStream |
fetchRawData(java.lang.String path,
java.time.Instant begin,
java.time.Instant end,
boolean bypassCache)
Gets raw data from the source as an output stream, for the time interval specified.
|
abstract byte[] |
onCacheMiss(java.lang.String path,
java.time.Instant begin,
java.time.Instant end)
Gets raw data from the source as an output stream, for the time interval specified.
|
fetchDecodedData, getBindingTree, getDecoder, getEncoding, getId, getParams, getSourceName, getTimeZoneId, isClosed, loadParams, onStart, ping, setId, toString, validateParameter, validateParameterNullitypublic static final int DEFAULT_CACHE_SIZE
public SimpleCachingDataAdapter()
SimpleCachingDataAdapter classpublic SimpleCachingDataAdapter(int maxCacheEntries)
SimpleCachingDataAdapter class with the specified maximum number of entriesmaxCacheEntries - the maximum number of entries in the cachepublic java.io.InputStream fetchRawData(java.lang.String path,
java.time.Instant begin,
java.time.Instant end,
boolean bypassCache)
throws DataAdapterException
DataAdapterfetchRawData in class DataAdapter<T,A extends Decoder<T>>path - the path of the data in the sourcebegin - the start of the time interval.end - the end of the time interval.*bypassCache - true if adapter cache should be bypassed, false otherwise. This parameter is ignored if adapter does not support cachingDataAdapterException - if an error occurs while retrieving data from the source.public abstract byte[] onCacheMiss(java.lang.String path,
java.time.Instant begin,
java.time.Instant end)
throws DataAdapterException
path - the path of the data in the sourcebegin - the start of the time interval.end - the end of the time interval.DataAdapterException - if an error occurs while retrieving data from the source.Copyright © 2018 Frederic Thevenet. All rights reserved.