Class Cache<K,V>
java.lang.Object
smile.util.Cache<K,V>
- Type Parameters:
K- the type of cache keys.V- the type of cache values.
An LRU (Least Recently Used) cache with TTL (Time To Live) combines
size-based eviction with time-based expiration.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Cache
Constructor.- Parameters:
capacity- the maximum number of entries in the cache.ttl- the time-to-live duration for each cache entry.
-
-
Method Details
-
keySet
-
valueSet
Returns the set of values in the cache. Expired entries will be evicted first.- Returns:
- the set of values in the cache.
-
put
Puts a value in the cache with the current timestamp. If the cache exceeds its capacity, the oldest entry will be evicted.- Parameters:
key- the cache key.value- the cache value.- Returns:
- the previous value associated with the key, or null if there was no mapping for the key.
-
get
-
remove
-