51Degrees Pipeline for Java

fiftyone.caching.LruLoadingCache< K, V > Class Template Reference

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 >:

[legend]

Collaboration diagram for fiftyone.caching.LruLoadingCache< K, V >:

[legend]

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.
get (K key)
 Retrieves the value for key requested.
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
cacheSizethe number of items to store in the cache
loaderthe 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
keyof the item required.
Returns
an instance of the value associated with the key
Exceptions
IllegalStateExceptionif 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
keyof the item required
loaderto fetch the items from
Returns
an instance of the value associated with the key
Exceptions
java.io.IOExceptionif 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
loaderthe loader to use