Interface Cache<K,V>
- Type Parameters:
K- type of cache keysV- type of cached values
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Simple cache interface.
No-op implementation (the one which never performs any caching) is considered correct.- API note
- currently java-commons does not implement its own functional cache, it simply provides a universal interface and wrappers for known implementations
-
Method Summary
-
Method Details
-
get
Gets the value from the cache computing it on demand using the provided function.- Parameters:
key- key by which ti get the value from cachemappingFunction- function used to create the value if there is no cached one- Returns:
- the current value associated with the specified key
- Throws:
NullPointerException- ifkeyisnullNullPointerException- ifmappingFunctionisnull
-
never
Creates a cache which actually never performs caching.- Type Parameters:
K- type of cache keysV- type of cached values- Returns:
- cache which actually never performs caching
-