Interface ICache<K,V>
- Type Parameters:
K
- the type of the cache keysV
- the type of the cache values
- All Known Implementing Classes:
StandardCache
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
Modifier and TypeMethodDescriptionvoid
clear()
Clear the entire cache.void
Clears a specific entry in the cache.Retrieve a value from the cache.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.keySet()
Returns all the keys contained in this cache.void
Insert a new value into the cache.
-
Method Details
-
put
Insert a new value into the cache.
- Parameters:
key
- the key of the new entryvalue
- the value to be cached
-
get
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
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
Clears a specific entry in the cache.
- Parameters:
key
- the key of the entry to be cleared.
-
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
-