Detailed Description
Uses the LruCacheBase to implement the LoadingCache interface.
- Parameters
-
<K> the type of key <V> the type of value
Inheritance diagram for fiftyone.caching.LruLoadingCache< K, V >:
Collaboration diagram for fiftyone.caching.LruLoadingCache< K, V >:
Classes | |
| class | Builder |
Implementation of CacheBuilder for LruLoadingCache caches. More... | |
Public Member Functions | |
| LruLoadingCache (int cacheSize, ValueLoader< K, V > loader) | |
| Constructs a new instance of the cache. | |
| void | setCacheLoader (ValueLoader< K, V > loader) |
| Set the loader used to fetch items not in the cache. | |
| V | get (K key) |
| Retrieves the value for key requested. | |
| V | get (K key, ValueLoader< K, V > loader) throws IOException |
| Retrieves the value for key requested. | |
Public Member Functions inherited from fiftyone.caching.LruCacheBase< K, V > | |
| long | getCacheSize () |
| The number of items the cache lists should have capacity for. | |
| long | getCacheMisses () |
| long | getCacheRequests () |
| double | getPercentageMisses () |
| void | resetCache () |
| Resets the 'stats' for the cache. | |
| void | close () |
Additional Inherited Members | |
Protected Member Functions inherited from fiftyone.caching.LruCacheBase< K, V > | |
| CachedItem | add (K key, V value) |
| void | close (boolean closing) |
Constructor & Destructor Documentation
◆ LruLoadingCache()
| fiftyone.caching.LruLoadingCache< K, V >.LruLoadingCache | ( | int | cacheSize, |
| ValueLoader< K, V > | loader ) |
Constructs a new instance of the cache.
- Parameters
-
cacheSize the number of items to store in the cache loader the loader used to fetch items not already in the cache
Member Function Documentation
◆ get() [1/2]
| V fiftyone.caching.LruLoadingCache< K, V >.get | ( | K | key | ) |
Retrieves the value for key requested.
If the key does not exist in the cache then the Fetch method of the cache's loader is used to retrieve the value.
- Parameters
-
key of the item required.
- Returns
- an instance of the value associated with the key
- Exceptions
-
IllegalStateException if there was a problem accessing data file
Reimplemented from fiftyone.caching.LruCacheBase< K, V >.
◆ get() [2/2]
| V fiftyone.caching.LruLoadingCache< K, V >.get | ( | K | key, |
| ValueLoader< K, V > | loader ) throws IOException |
Retrieves the value for key requested.
If the key does not exist in the cache then the Fetch method is used to retrieve the value from another loader.
- Parameters
-
key of the item required loader to fetch the items from
- Returns
- an instance of the value associated with the key
- Exceptions
-
java.io.IOException if there was a problem accessing data file
Implements fiftyone.caching.LoadingCache< K, V >.
◆ setCacheLoader()
| void fiftyone.caching.LruLoadingCache< K, V >.setCacheLoader | ( | ValueLoader< K, V > | loader | ) |
Set the loader used to fetch items not in the cache.
- Parameters
-
loader the loader to use
