com.liferay.faces.util.cache
Interface Cache<K,V>

All Known Implementing Classes:
CacheWrapper

public interface Cache<K,V>

This class contains a minimal set of methods required to manipulate a cache of key+value pairs.

Since:
3.1, 2.1, 1.1
Author:
Kyle Stiemann

Method Summary
 boolean containsKey(K key)
          Returns true if the key (and therefor a corresponding value) is present in the cache or false otherwise.
 Set<K> getKeys()
          Returns the set of all keys currently in the cache at the time this method was called.
 int getSize()
          Returns the number of key-value pairs in the cache.
 V getValue(K key)
          Returns the cached value that is mapped to this key or null if the value is not in the cache.
 V putValueIfAbsent(K key, V value)
          Puts the cached key-value pair into the cache if the key does not already exist in the cache.
 V removeValue(K key)
          Removes an entry from the cache.
 

Method Detail

containsKey

boolean containsKey(K key)
Returns true if the key (and therefor a corresponding value) is present in the cache or false otherwise.

Parameters:
key - The key that the value is mapped to.

getKeys

Set<K> getKeys()
Returns the set of all keys currently in the cache at the time this method was called.


getSize

int getSize()
Returns the number of key-value pairs in the cache.


getValue

V getValue(K key)
Returns the cached value that is mapped to this key or null if the value is not in the cache.

Parameters:
key - The key that the value is mapped to.

putValueIfAbsent

V putValueIfAbsent(K key,
                   V value)
Puts the cached key-value pair into the cache if the key does not already exist in the cache. If the key was not already added to the cache, this method returns the passed value for convenience. Otherwise this method returns the value associated with the key from the cache.

Parameters:
key - The key that the value is mapped to.
value - The value to be cached.

removeValue

V removeValue(K key)
Removes an entry from the cache. Returns the value of the removed key-value pair.

Parameters:
key - The key that the value is mapped to.


Copyright © 2019 Liferay, Inc.. All rights reserved.