Interface ICache<K,V>
-
- Type Parameters:
K
- the type of the cache keysV
- the type of the cache values
- All Known Implementing Classes:
StandardCache
public interface ICache<K,V>
Common interface for all the cache objects used by the template engine.
This is the interface that must be implemented by all cache objects managed by
ICacheManager
implementations.- Since:
- 2.0.0
- Author:
- Daniel Fernández
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
clear()
Clear the entire cache.void
clearKey(K key)
Clears a specific entry in the cache.V
get(K key)
Retrieve a value from the cache.V
get(K key, ICacheEntryValidityChecker<? super K,? super V> validityChecker)
Retrieve a value from the cache, using the specified validity checker to ensure the entry is still valid.Set<K>
keySet()
Returns all the keys contained in this cache.void
put(K key, V value)
Insert a new value into the cache.
-
-
-
Method Detail
-
put
void put(K key, V value)
Insert a new value into the cache.
- Parameters:
key
- the key of the new entryvalue
- the value to be cached
-
get
V get(K key)
Retrieve a value from the cache.
- Parameters:
key
- the key of the value to be retrieved- Returns:
- the retrieved value, or null if no value exists for the specified key.
-
get
V get(K key, ICacheEntryValidityChecker<? super K,? super V> validityChecker)
Retrieve a value from the cache, using the specified validity checker to ensure the entry is still valid. If the cache already has a default validity checker, this method should override this setting and use the one specified instead.
- Parameters:
key
- the key of the value to be retrievedvalidityChecker
- the validity checker to be used to ensure the entry is still valid.- Returns:
- the retrieved value, or null if no value exists for the specified key.
-
clear
void clear()
Clear the entire cache.
-
clearKey
void clearKey(K key)
Clears a specific entry in the cache.
- Parameters:
key
- the key of the entry to be cleared.
-
keySet
Set<K> keySet()
Returns all the keys contained in this cache. Note this method might return keys for entries that are already invalid, so the result of calling
get(Object)
for these keys might benull
.- Returns:
- the complete set of cache keys. Might include keys for already-invalid (non-cleaned) entries.
- Since:
- 3.0.0
-
-