\r\n

51Degrees Pipeline Java  4.4

51Degrees Pipeline for Java

fiftyone.caching.LruCacheBase< K, V > Class Template Reference abstract

Detailed Description

This is a Least Recently Used (LRU) cache with multiple linked lists in place of the usual single linked list.

The linked list to use is assigned at random and stored in the cached item. This will generate an even set of results across the different linked lists. The approach reduces the probability of the same linked list being locked when used in a environments with a high degree of concurrency. If the feature is not required then the constructor should be provided with a concurrency value of 1 so that a single linked list is used.

Although this cache is written to be very generic, the primary use-case is to provide a result cache for Aspect Engines in the Pipeline API.

See also
Specification
Parameters
<K> - key for the cache items
<V> - value for the cache items

Inheritance diagram for fiftyone.caching.LruCacheBase< K, V >:

[legend]

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

[legend]

Classes

class  CachedItem
An item stored in the cache along with references to the next and previous items.
class  CacheLinkedList
A linked list used in the LruCache implementation.

Public Member Functions

long  getCacheSize ()
The number of items the cache lists should have capacity for. More...
long  getCacheMisses ()
long  getCacheRequests ()
double  getPercentageMisses ()
V  get (K key)
Retrieves the value for key requested. More...
void  resetCache ()
Resets the 'stats' for the cache.
void  close ()

Protected Member Functions

CachedItem  add (K key, V value)
void  close (boolean closing)

Member Function Documentation

◆ get()

V fiftyone.caching.LruCacheBase< K, V >.get ( K   key )

Retrieves the value for key requested.

Parameters
key - or the item required
Returns
an instance of the value associated with the key or null

Implements fiftyone.caching.Cache< K, V >.

◆ getCacheMisses()

long fiftyone.caching.LruCacheBase< K, V >.getCacheMisses ( )
Returns
number of cache misses.

◆ getCacheRequests()

long fiftyone.caching.LruCacheBase< K, V >.getCacheRequests ( )
Returns
number of requests received by the cache.

◆ getCacheSize()

long fiftyone.caching.LruCacheBase< K, V >.getCacheSize ( )

The number of items the cache lists should have capacity for.

Returns
capacity of the cache.

◆ getPercentageMisses()

double fiftyone.caching.LruCacheBase< K, V >.getPercentageMisses ( )
Returns
the percentage of times cache request did not return a result.
On This Page