Top Description Fields Constructors Methods
waffle.util.cache

public Class CaffeineCache<K, V>

extends Object
implements Cache<K, V>
Class Inheritance
All Implemented Interfaces
waffle.util.cache.Cache
Type Parameters
<K>
the type of keys maintained by this cache
<V>
the type of mapped values
Imports
com.github.benmanes.caffeine.cache.Caffeine, java.time.Duration, org.checkerframework.checker.index.qual.NonNegative

A Cache based on com.github.benmanes.caffeine.cache.Cache
Author
Simon Legner

Field Summary

Modifier and TypeField and Description
private final Cache<K, V>
cache

The cache store.

Constructor Summary

AccessConstructor and Description
public
CaffeineCache(final @NonNegative long
Specified timeout in seconds for cache.
timeout
)

Instantiate new caffeine cache with timeout.

Method Summary

Modifier and TypeMethod and Description
public V
get(K
the key
key
)

Implements waffle.util.cache.Cache.get.

Fetches the key from the cache
public void
put(K
the key
key
,
V
the value
value
)

Implements waffle.util.cache.Cache.put.

Stores a binding for the key and the value in the cache
public void
remove(K
the key
key
)

Implements waffle.util.cache.Cache.remove.

Removes the binding for the key from the cache
public int
size()

Implements waffle.util.cache.Cache.size.

Returns the number of bindings in this cache
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cacheback to summary
private final Cache<K, V> cache

The cache store.

Constructor Detail

CaffeineCacheback to summary
public CaffeineCache(final @NonNegative long timeout)

Instantiate new caffeine cache with timeout.

Parameters
timeout:@NonNegative long

Specified timeout in seconds for cache.

Method Detail

getback to summary
public V get(K key)

Implements waffle.util.cache.Cache.get.

Doc from waffle.util.cache.Cache.get.

Fetches the key from the cache

Parameters
key:K

the key

Returns:V

the corresponding value

Annotations
@Override
putback to summary
public void put(K key, V value)

Implements waffle.util.cache.Cache.put.

Doc from waffle.util.cache.Cache.put.

Stores a binding for the key and the value in the cache

Parameters
key:K

the key

value:V

the value

Annotations
@Override
removeback to summary
public void remove(K key)

Implements waffle.util.cache.Cache.remove.

Doc from waffle.util.cache.Cache.remove.

Removes the binding for the key from the cache

Parameters
key:K

the key

Annotations
@Override
sizeback to summary
public int size()

Implements waffle.util.cache.Cache.size.

Doc from waffle.util.cache.Cache.size.

Returns the number of bindings in this cache

Returns:int

the size

Annotations
@Override